我如何在React Native CLI中使用Firebase实现电话验证?

huangapple go评论61阅读模式
英文:

How do I implement phone auth using firebase in react native cli?

问题

最初,我使用Firebase实现了Google登录,现在我想在Firebase中实现电话验证。

以下是我遵循的步骤:

  1. 启用电话登录提供程序。
  2. 添加SHA证书指纹。
    然后按照RN Firebase文档提供的代码进行操作。

但是我遇到了以下错误:

> 错误:[auth/app-not-authorized] 该应用程序未获授权使用Firebase身份验证。请验证Firebase控制台中是否配置了正确的包名称和SHA-1。[play_integrity_token中的请求字段无效]
>
> NativeFirebaseError:[auth/app-not-authorized] 该应用程序未获授权使用Firebase身份验证。请验证Firebase控制台中是否配置了正确的包名称和SHA-1。[play_integrity_token中的请求字段无效]

如何解决这个问题?

英文:

Initially, I implemented google sign in using Firebase and now I want to implement phone auth in firebase.

Here are the steps, I followed,

  1. Enabled the phone sign-in providers.
  2. Added SHA certificate fingerprints.
    and Rest followed the code provided by RN Firebase docs

And I'm getting an error like

> Error: [auth/app-not-authorized] This app is not authorized to use Firebase Authentication. Please verify that the correct package name and SHA-1 are configured in the Firebase Console. [ Invalid request fields in play_integrity_token ]
>
> NativeFirebaseError: [auth/app-not-authorized] This app is not authorized to use Firebase Authentication. Please verify that the correct package name and SHA-1 are configured in the Firebase Console. [ Invalid request fields in play_integrity_token ]

How to solve this?

答案1

得分: 1

我遇到了相同的问题,我认为我已经找到了解决方法,截至2023年6月对我有效。以下是我所做的:

  1. 检查 SHA-1 和 SHA-256,分别来自本地生成和 Play 商店,在 "发布" > "设置" > "应用完整性" > "应用签名" 中,这是您在 Firebase 项目设置中设置的。
  2. @react-native-firebase/auth 升级到 v17.x.x。从 v17.x.x 开始支持 Play 完整性。
  3. 在在线临时手机号码或真实设备上测试可用的移动号码,似乎 Play 完整性只适用于已签名的发布版。
  4. React Native Firebase 仅建议确保完成步骤 1 和 2,但没有提到 "开始之前的步骤"。明确地说,它应该在 /app/build.gradle 中,而不是在 Firebase 文档中定义的 /build.gradle。请参考截图:

我如何在React Native CLI中使用Firebase实现电话验证?

最后,请确保在 Play 商店上传 .aab 时没有关于 safenet 废弃的警告。

希望能帮助您,否则,我将很乐意听取更新的解决方案。截止到我撰写这篇文章时,我无法在一个地方找到解决方案,不得不在不同的地方自己摸索。

英文:

I encounter the same issue and I think I figure it out, which works for me as of June 2023. Here's what i've done:

  1. Review SHA-1 and SHA-256 from both locally generated and playstore under Release > Setup > App Integrity > App Signing you set in firebase project settings.
  2. Upgrade @react-native-firebase/auth to v17.x.x. Play Integrity is supported starting v17.x.x
  3. Test temporary mobile number available online or real mobile number in a real device (not simulator), it seems that Play Integrity only works with a signed release
  4. React Native Firebase only suggest to make sure you complete step 1 and 2 but not mentioned "before we begin steps". To be clear, it should be in /app/build.gradle and not /build.gradle as define in firebase docs. See screenshot:

我如何在React Native CLI中使用Firebase实现电话验证?

Lastly, make sure when upload .aab in playstore you didn't get warning about safenet deprecation

Hope it helps, otherwise, I would be happy to hear what are updated solutions. As of this writing, I can't find a solution in one place. I had to figure out this myself in different places.

huangapple
  • 本文由 发表于 2023年5月28日 14:44:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76350268.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定