google 的 Firebase React Native Expo 登录错误

Firebase React Native Expo login error with google

错误信息:(0, _auth.signInWithRedirect) is not a function. (In '(0, _auth.signInWithRedirect)(_firebaseConfig.authentication, _firebaseConfig.provider)', '(0, _auth.signInWithRedirect)' is undefined)


即使我做对了所有事情,它也会出现这个错误。它在网络上有效,但我在 android phone.

上收到此错误

我的登录函数:

const signInWithGoogle = async () => {
    try {
        const result = await signInWithRedirect(authentication, provider);
        const user = result.user;
        console.log(user)
    }
    catch (error) {
        const errorMessage = error.message;
        console.log(errorMessage)
    };
}

signInWithRedirect 在 React Native 中不起作用。来自 Firebase blog -

Headful" auth methods such as signInWithPopup(), signInWithRedirect(), linkWithPopup(), and linkWithRedirect() do not work in React Native (or Cordova, for that matter). You can still sign in or link with a federated provider by using signInWithCredential() with an OAuth token from your provider of choice.

您可以使用 signInWithCredential 或使用 React Native Firebase