我已经使用下面的代码成功地在Firebase的RN应用程序中实现了谷歌签名。当我第一次点击按钮时,它会创建FB帐户。。。。然后它会让我登录。
一切都很好。。。。。但当我点击登录时,它会不时返回statusCodes.IN_PROGRESS
的错误代码我想能够处理这个错误(通过终止登录或其他方式??(,但不知道如何。。。。。有人能帮忙吗?
p.s.导致错误的确切代码行=const {accessToken, idToken} = await GoogleSignin.signIn();
。。。。。它也给了我这个警告Warning: previous promise did not settle and was overwritten. You've called "signIn" while "signIn" was already in progress and has not completed yet.
import firebase from '@react-native-firebase/app';
import auth from '@react-native-firebase/auth';
import {GoogleSignin, statusCodes} from '@react-native-community/google-signin';
import {LoginManager, AccessToken} from 'react-native-fbsdk';
export const _getFbGoogleCredential = async () => {
await GoogleSignin.hasPlayServices();
const {accessToken, idToken} = await GoogleSignin.signIn();
const firebaseCredential = await auth.GoogleAuthProvider.credential(idToken, accessToken);
return firebaseCredential;
};
export const _googleSignIn = async () => {
try {
const firebaseCredential = await _getFbGoogleCredential();
const fbUserObj = await auth().signInWithCredential(firebaseCredential);
} catch (error) {
if (error.code === 'auth/account-exists-with-different-credential') {
//xx
} else if (error.code === statusCodes.SIGN_IN_CANCELLED) {
//xx
} else if (error.code === statusCodes.IN_PROGRESS) {
//HERE IS THE ISSUE
} else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
//xx
} else {
//xx
}
}
};
我也有同样的错误
警告:以前的承诺未结算,已被覆盖。你打电话给"登录";而";"登录";已在进行中,尚未完成。
并且我能够通过NOT使用包@react-native-google-signin/google-signin
附带的GoogleSigninButton
来修复
GoogleSigninButton
有一个错误,所以只需使用任何其他按钮组件。。。奇怪的修复,但嘿,它有效。看看罪魁祸首