如何解决反应本机Google登录@ react-native-community / google-signin error.code === statusCodes.IN_PROGRESS
我已使用Firebase使用以下代码成功实现了Google登录到我的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
}
}
};
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。