0

我正在尝试在我的应用程序中提供 Firebase 无密码身份验证。我按照原样遵循了文档。

val actionCodeSettings = ActionCodeSettings.newBuilder().apply {
            url = "https://appname.no/email_verify/"
            handleCodeInApp = true
            iosBundleId = iosBundleId
            setAndroidPackageName(
                androidPackageName,
                true, /* installIfNotAvailable */
                "0" /* minimumVersion */
            )
        }.build()

btnSubmit.onClick {
            pDialog?.show()
            Firebase.auth.sendSignInLinkToEmail(etEmail.value ?: "", actionCodeSettings)
                .addOnSuccessListener {
                    pDialog?.dismiss()
                    prefs.email = etEmail.value
                    Toast.makeText(this@LoginActivity, "Email sent to ${prefs.email}.", Toast.LENGTH_SHORT).show()
                    Timber.d("Email sent.")
                }
                .addOnCanceledListener {
                    Timber.d("Email cancelled.")
                    pDialog?.dismiss()
                }
                .addOnFailureListener {
                    Timber.d("Email sending failed: ${it.message}.")
                    pDialog?.dismiss()
                    it.printStackTrace()
                }
        }

这是意图过滤器

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

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

            <data android:host="links.appname.no" android:scheme="https" />
 </intent-filter>

当我通过 Android Studio 通过 USB 安装应用程序时,当我单击电子邮件中的链接时,它只会在安装应用程序时打开应用程序。但是,如果我通过 Play 商店或命令安装发布版本,它会要求我在浏览器或我的应用程序之间进行选择以打开链接。在一台设备中,链接直接在浏览器中打开,而不是重定向到应用程序。

当我在浏览器中打开链接时,这就是我看到的

在此处输入图像描述

我尝试android:autoVerify:"true"按照此论坛的一些答案中的建议删除。还尝试在 Intent Filter 中拆分schemeand hostin<data/>标记。这些都不起作用。

有没有办法从浏览器重定向到应用程序或仅在应用程序中打开链接而不允许用户转到浏览器?要么会工作。

4

0 回答 0