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

Firebase Phone Auth跳转至浏览器问题排查求助

Firebase OTP 跳转浏览器问题排查(替代已废弃的Device Verification API)

使用Firebase Auth发送OTP时,始终跳转至手机浏览器,原依赖的Device Verification API已废弃,已完成以下操作但问题未解决:

  • 启用Play Integrity API
  • 添加了调试/发布版的SHA1、SHA256指纹到Firebase控制台
  • 导入了Firebase配置文件
  • 尝试卸载重装应用、切换Release构建变体

当前依赖项:

// Import the BoM for the Firebase platform
implementation(platform("com.google.firebase:firebase-bom:32.2.0"))
implementation("com.google.firebase:firebase-auth")
implementation("com.google.firebase:firebase-crashlytics")
implementation("com.google.firebase:firebase-analytics")
implementation 'com.google.android.play:integrity:1.2.0'
implementation 'androidx.browser:browser:1.5.0'

排查要点

  • 确认Play Integrity验证已启用
    Firebase Auth需要明确开启Play Integrity验证来替代旧的Device Verification API,确保调用PhoneAuthOptions时添加了setForcePlayIntegrityToken(true)配置:

    val phoneAuthOptions = PhoneAuthOptions.newBuilder(FirebaseAuth.getInstance())
        .setPhoneNumber(phoneNumber)
        .setTimeout(60L, TimeUnit.SECONDS)
        .setActivity(this)
        .setCallbacks(callbacks)
        .setForcePlayIntegrityToken(true) // 关键配置,必须开启
        .build()
    PhoneAuthProvider.verifyPhoneNumber(phoneAuthOptions)
    
  • 检查Firebase控制台的设备验证设置
    进入Firebase控制台 -> 目标项目 -> Authentication -> Sign-in method -> Phone,在高级选项中,确认设备验证方式已切换为Play Integrity,而非已废弃的Device Verification。

  • 验证SHA指纹的完整性与全面性

    1. 用命令重新确认当前构建变体的签名指纹,确保与Firebase控制台记录一致:
      # 调试版指纹
      keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore
      # 发布版指纹
      keytool -list -v -keystore /path/to/your/release/keystore.jks
      
    2. 若应用使用Google Play App Signing,需将Google Play生成的应用签名密钥指纹也添加到Firebase控制台(仅上传密钥指纹不够)。
  • 检查Play Integrity API的状态
    进入Google Cloud控制台 -> 目标项目 -> APIs & Services,确认Play Integrity API已启用,且没有触发配额限制;同时确保项目服务账号拥有Play Integrity的访问权限。

  • 升级依赖版本
    当前使用的Play Integrity 1.2.0和Firebase BOM 32.2.0存在已知兼容性问题,尝试升级到最新稳定版:

    implementation(platform("com.google.firebase:firebase-bom:29.2.1")) // 或最新稳定版
    implementation 'com.google.android.play:integrity:1.3.0'
    
  • 确认设备Google Play服务版本
    旧版Google Play服务可能不支持Play Integrity的验证流程,确保测试设备上的Google Play服务已更新至最新版本。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.14 01:52:17