Expo-go 是一个使用 Firebase 中的 Google 身份验证的 React-Native 应用程序。

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

Expo-go React-Native application that uses Google Authentication in Firebase

问题

我正在使用Expo构建React-Native应用程序,并使用Expo Go进行测试。我需要使用Google来对Firebase用户进行身份验证。

我成功地使用电子邮件+密码对Firebase用户进行了身份验证,但无法使用Google进行身份验证。

我已经花了好几天的时间在网络(以及Stack Overflow)上寻找解决方案,但没有找到明确的或真正有效的示例。

提出的方法包括:'signInWithRedirect'和'signInWithPopup'(在React-Native中都不适用),'expo-google-sign-in'(已弃用)和'Expo-auth-session'(似乎是最新的方法,但很多人声称它在expo-go中不起作用)。

我正在尝试的事情是否可能?是否有任何可用的示例?

否则,有没有推荐的方法来在我的应用程序中使用Google对Firebase用户进行身份验证(例如,使用构建而不是expo-go,或使用Expo Dev Clients来增强expo-go等)?请提供任何有效的示例。

非常感谢,我感到非常绝望 Expo-go 是一个使用 Firebase 中的 Google 身份验证的 React-Native 应用程序。

英文:

I am building a React-Native application with expo and test it with expo-go. I need to authenticate users to Firebase using Google.
I managed to authenticate users in Firebase with email+password, but not with Google.

I have spent several days looking for solutions on the web (and Stack-Overflow) and could not find anything definite or an example that actually works.
The proposed methods were: 'signInWithRedirect' and 'signInWithPopup' (both do not work in React-Native), 'expo-google-sign-in' (deprecated) and 'Expo-auth-session' (seems to be the latest method, but many claim it does not work with expo-go).

Is what I try to do even possible? is there a working example anywhere?

Otherwise, what would be the recommended way to authenticate users with Google in Firebase in my application (e.g., use builds instead of expo-go, or use Expo Dev Clients to enhance expo-go, etc.) - any working example please?

Many thanks in advance, I am getting desperate Expo-go 是一个使用 Firebase 中的 Google 身份验证的 React-Native 应用程序。

答案1

得分: 1

我成功地通过Expo SDK 47在Expo Go上使Firebase Google身份验证工作。随着2023年2月发布的Expo SDK 48,我认为在Expo Go上无法再使其工作。请参阅SDK 48更新的说明

我曾不愿迁移到Expo Dev Clients,但它比预期的顺利,所以我建议勇敢尝试并继续使用Expo Dev Client。我认为您需要一个付费的苹果开发者帐户来创建构建。我使用这种方法遇到的另一个问题是,我似乎无法在预览构建中使身份验证流程工作,尽管在开发构建中可以正常工作。请参阅我的问题此处,其中嵌入了我的代码示例,该示例在开发构建中可以正常工作。

英文:

I managed to get firebase google auth working through Expo Go using Expo SDK 47. With the release of Expo SDK 48 in February 2023, I believe it is no longer possible to get it working with Expo Go. See explanation of the SDK 48 updates here.

I was reluctant to migrate to Expo Dev Clients, but it went smoother than anticipated, so I would recommend biting the bullet and moving forward with Expo Dev Client. I believe you will need a paid apple developer account to create the builds. The other issue I'm having with this method, is that I cannot seem to get the authentication flow working in a preview build, although it works fine in the development build. See my question here which has my code sample embedded, which works with the development build.

答案2

得分: 0

经过浪费了荒谬的时间(大约一周)后,我最终放弃了,转而使用React-Native CLI而不是Expo。仅仅几个小时之内,使用React-Native-Firebase包(使用原生代码)进行Google身份验证时,我没有遇到任何问题。

(顺便说一句 - 我尝试在dev-client中使用React-Native-Firebase,但无法使其正常工作)

英文:

After spending a ridiculous amount of time on this (about a week) I finally gave up and moved to React-Native CLI instead of Expo.
In just a few hours, using the React-Native-Firebase package (that uses native code) I had no problems authenticating with Google.

(BTW - I tried to use React-Native-Firebase in a dev-client, but was not able to make it work)

答案3

得分: 0

抱歉,代码部分不提供翻译。以下是已翻译的部分:

"A bit late to the party guys, but we've just spent about 2 days making it work. Check out our blog post about it. It is definitely possible, even with Expo SDK 48. There is a link in the blog post to a git repo included where you can find a working example. Hope it helps some of you. :)"

英文:

A bit late to the party guys, but we've just spent about 2 days making it work. Check out our blog post about it. It is definitely possible, even with Expo SDK 48. There is a link in the blog post to a git repo included where you can find a working example. Hope it helps some of you. Expo-go 是一个使用 Firebase 中的 Google 身份验证的 React-Native 应用程序。

huangapple
  • 本文由 发表于 2023年4月4日 09:34:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/75924863.html
匿名

发表评论

匿名网友

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

确定