【问题标题】:Firebase Android: Email Link Authentication. intent-filter not workingFirebase Android:电子邮件链接身份验证。意图过滤器不起作用
【发布时间】:2018-05-04 13:19:54
【问题描述】:

我正在为 Android 实施 firebase 电子邮件链接身份验证机制。 我已经使用firebase的指南实现了它。 但是现在从电子邮件打开链接后,应用程序总是会进入启动器活动。我无法调试该问题。 我还在我的应用程序中实现了动态链接,并且效果很好。 这是我的意图过滤器:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.BROWSABLE" />
    <category android:name="android.intent.category.DEFAULT" />

    <data android:scheme="http" />
    <data android:scheme="https" />
    <data android:host="www.example.com" />
    <data android:pathPrefix="/emailSignInLink" />

</intent-filter>

这是我正在使用的 ActionCodeSetting:

ActionCodeSettings settings = ActionCodeSettings.newBuilder()
                .setAndroidPackageName(
                        BuildConfig.APPLICATION_ID,
                        false, /* install if not available? */
                        null   /* minimum app version */)
                .setHandleCodeInApp(true)
                .setUrl("https://www.example.com/emailSignInLink")
                .build();

谁能弄清楚我在这里做错了什么或遗漏了什么

来自 firebase 的样本:

https://github.com/firebase/quickstart-android/blob/master/auth/app/src/main/AndroidManifest.xml

https://github.com/firebase/quickstart-android/blob/master/auth/app/src/main/java/com/google/firebase/quickstart/auth/PasswordlessActivity.java

编辑 1:

我通过在启动器活动的 onResume 数据中记录意图数据进行了检查,并且我得到了由 firebase 身份验证返回的数据,因此我认为动态链接似乎存在某种问题。

我的 firebase 邀请版本是 15.0.0,因为 15.0.2 给了我错误(在文档中更新但我认为实际上并未发布。)

implementation "com.google.firebase:firebase-invites:15.0.0"

编辑 2: 使用 firebase 示例进行无密码登录示例时也会出现同样的问题。我在 GitHub 上创建了一个问题

https://github.com/firebase/quickstart-android/issues/488

【问题讨论】:

  • 这个意图过滤器是否在您的愿望活动中定义?
  • 是的,意图过滤器在所需的活动中,但该活动不是我的启动器活动(即它没有启动器意图过滤器)。
  • 域被列入白名单,因为此过程在发送电子邮件之前失败并抛出域未列入白名单的错误。
  • 您能否尝试将意图过滤器中的主机/路径替换为电子邮件链接中 link= 值中的域,并确保它已在 Firebase 控制台的 Auth 部分获得授权?应该看起来像 .firebaseapp.com

标签: android firebase firebase-authentication


【解决方案1】:

我和你有同样的问题。 为了解决这个问题,我删除了 pathPrefix 并设置了我的域的 url,而不是意图过滤器中的动态链接,它似乎可以工作。

 <intent-filter>
      <action android:name="android.intent.action.VIEW" />
      <data
           android:scheme="https"
           android:host="myfirebaseId.firebaseapp.com"/>
      <category android:name="android.intent.category.BROWSABLE" />
      <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

希望对你有帮助

【讨论】:

  • 这帮帮我,谢谢!但是另外,它需要为每个设置一个
【解决方案2】:

我和你有同样的问题。我已经解决了。 在清单中,在 android:host 我确实放了一个动态链接域!

就像https://firebase.google.com/docs/dynamic-links/android/receive中所说的那样

请注意,android:host 必须设置为您的动态链接域, 而不是您的深层链接的域。

在清单中:

<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.BROWSABLE" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:host="myDynamicLink.page.link" android:scheme="https" />
</intent-filter>

在我的次要活动中:

ActionCodeSettings actionCodeSettiongs = ActionCodeSettings.newBuilder()
        .setAndroidPackageName(getPackageName(), false, null)
        .setHandleCodeInApp(true)
        .setUrl("https://auth.example.com")
        .build();

为我的电子邮件生成的 URL 如下所示: "https://myDynamicLink.page.link/?link=https://myApp.firebaseapp.com...continueUrl%3Dhttps://auth.example.com..."


附注这一切都令人困惑,因为他们在他们的指南中作为示例放置了链接“https://example.com”,而不是“http://example.page.link

【讨论】:

  • @Skav 的选项效果不佳,因为他使用了应用链接(非动态)。 android:host="myfirebaseId.firebaseapp.com"/> 在这种情况下,它不会为您的活动传递 intent.mData
猜你喜欢
  • 2019-05-20
  • 2022-10-13
  • 1970-01-01
  • 2018-09-02
  • 1970-01-01
  • 2023-03-18
  • 2019-05-08
  • 1970-01-01
  • 2020-05-11
相关资源
最近更新 更多