遵循GitHub上的设置指南(适用于Android)之后 https://github.com/react-native-community/react-native-google-signin
我能够将软件包和signIn按钮成功添加到我的应用程序中,但是,当我单击它时,出现未知错误,请检查此代码上的else块。 “发生了其他错误”
_signIn = async () => {
try {
await GoogleSignin.hasPlayServices();
const userInfo = await GoogleSignin.signIn();
console.log('userInfo...');
console.log(userInfo);
this.setState({ userInfo });
} catch (error) {
if (error.code === statusCodes.SIGN_IN_CANCELLED) {
console.log('cancelled the login flow...');
} else if (error.code === statusCodes.IN_PROGRESS) {
console.log('operation (f.e. sign in) is in progress already');
} else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
console.log('play services not available or outdated');
} else {
console.log('some other error happened');
}
}
};
按钮。
<View style={styles.container}>
<GoogleSigninButton
style={{ width: 192, height: 48 }}
size={GoogleSigninButton.Size.Wide}
color={GoogleSigninButton.Color.Dark}
onPress={this._signIn}
disabled={false} />
</View>
如果有人可以澄清OAuth webClientId ,我应该在firebase控制台中使用哪一个,因为因为我同时看到应用程序和Web,所以设置中没有提及androidClientId。
GoogleSignin.configure({
webClientId: 'xxxxxxx.apps.googleusercontent.com',
GoogleService-Info.plist)
});