簡體   English   中英

為什么 Firebase (onAuthStateChanged) 看不到 Google 注冊用戶(使用 signInWithCredential)?

[英]Why Firebase (onAuthStateChanged) does not see a Google signup user (with signInWithCredential)?

因此,我按照本教程介紹了如何使用rnfirebase和 google 注冊來登錄用戶。 它工作正常。 這是代碼:

const googleSignUp = async () => {
  // Get the users ID token
  const { idToken } = await GoogleSignin.signIn();

  // Create a Google credential with the token
  const googleCredential = auth.GoogleAuthProvider.credential(idToken);

  // Sign-in the user with the credential
  const user = auth().signInWithCredential(googleCredential);

  return { idToken, user };
};

(讓我在這里注意,該應用程序已經使用 email 和密碼方式登錄,使用 Firebase)。

然后我意識到用戶不能更改他的名字 email 或刪除他的帳戶。 深入研究,我發現onAuthStateChanged(firebase.auth, async (user) =>...為用戶返回null

我在一些較舊的答案中看到,如果您使用 Google 注冊,您需要使用我使用的signInWithCredential注冊用戶,所以這不是問題。

對於電子郵件/密碼登錄,我使用來自Firebase web而不是來自rnfirebase的代碼會不會是一個問題? 雖然我已經有了這些的組合,但使用來自rnfirebase的推送通知。

有人可以解釋為什么我會出現這種行為,以及如何解決它嗎?

謝謝!

If I understand correctly, you use both the react-native-firebase library (which wraps the native iOS and Android SDKs) and the JavaScript Web SDK for Firebase in your app.

如果是這種情況,兩者確實都有單獨的登錄 state,並且登錄其中一個不會觸發onAuthStateChanged偵聽器。

您必須選擇一個 SDK 來通過 Firebase 進行身份驗證,然后將其用於兩個提供商。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM