You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Firebase Auth调用setTosAndPrivacyPolicyUrls后链接不可点击问题

我按照Firebase官方指引,使用目前可找到的最新版本依赖进行实现:

implementation 'com.facebook.android:facebook-login:12.0.1'
implementation 'com.facebook.android:facebook-android-sdk:12.0.1'
implementation 'com.firebaseui:firebase-ui-auth:7.2.0'

我使用了自定义布局,相关代码如下:

<TextView
    android:id="@+id/terms_and_conditions"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:autoLink="all"
    android:fontFamily="@font/omnes_light"
    android:gravity="center"
    android:linksClickable="true"
    android:paddingLeft="20dp"
    android:paddingRight="20dp"
    android:paddingBottom="20dp"
    android:textSize="16dp"
    android:text="@string/terms_and_conditions_login"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent" />

我也尝试过交替添加、移除如下两行配置:

android:linksClickable="true"
android:text="@string/terms_and_conditions_login"

同时也移除了tools:text属性。

对应的字符串资源定义如下:

<string name="terms_and_conditions_login">By continuing, you are indicating that you accept\nour <a href="https://www.mycompany.com/terms-conditions/">Terms of Service</a> and <a href="https://www.mycompany.com/privacy-policy/">Privacy Policy</a>.</string>

我的登录逻辑代码如下:

private fun login() {
    val selectedProviders = mutableListOf<AuthUI.IdpConfig>()
    selectedProviders.add(AuthUI.IdpConfig.GoogleBuilder().build())
    selectedProviders.add(AuthUI.IdpConfig.FacebookBuilder().build())
    selectedProviders.add(AuthUI.IdpConfig.EmailBuilder().build())


    val customLayout = AuthMethodPickerLayout
            .Builder(R.layout.activity_login_init)
            .setGoogleButtonId(R.id.google_button)
            .setFacebookButtonId(R.id.facebook_button)
            .setEmailButtonId(R.id.email_button)
            .setTosAndPrivacyPolicyId(R.id.terms_and_conditions)
            .build()


    val authUi = AuthUI.getInstance().createSignInIntentBuilder()
            .setAuthMethodPickerLayout(customLayout)
            .setAvailableProviders(selectedProviders)
            .setTheme(R.style.AppTheme_NoActionBar)
            .setIsSmartLockEnabled(false)
            .enableAnonymousUsersAutoUpgrade()
            .setTosAndPrivacyPolicyUrls("https://www.mycompany.com/terms-conditions/", "https://www.mycompany.com/privacy-policy/")
            .build()

    signInLauncher.launch(authUi)

}

当前现象:所有登录按钮功能正常,但页面底部的服务条款文本仅“Privacy Policy”字样显示为蓝色,所有链接均无法点击。同时正如相关公开问题所提到的,进入Google登录流程时,点击两个链接均报错“未找到可打开此链接的浏览器”。
进入Facebook登录流程时,仅隐私政策链接可正常跳转,服务条款链接无法使用;邮箱登录流程下两个链接均完全正常。我已核验所有链接本身可正常访问。

请问各位有没有办法可以解决这个问题?

2022年7月17日更新:我已在Firebase官方Github仓库提交该问题,近日得到官方回复,建议移除自定义布局TextView的android:autoLink属性。该方案部分解决了我的问题:目前主登录页的两个链接已可正常点击跳转至对应页面。
但仍存在问题:进入Google登录流程后点击两个蓝色链接仍会报错“未找到可打开此链接的浏览器”;Facebook登录流程中服务条款链接会跳转至404错误地址(我配置的链接是ourwebsite.../terms-conditions/,但实际会请求ourwebsite..../terms-of-service/);仅邮箱登录流程下链接功能完全正常。目前仅取得部分进展,仍求完整解决方案。


内容的提问来源于stack exchange,提问作者Kibi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.28 18:57:00