世博会反应原生谷歌身份验证与火力基地在安卓上发布的 apk 版本中不起作用



我想在我的应用程序中包含谷歌身份验证,但它在 android 上的发布版本中不起作用,即使它适用于世博会 这是代码:

logInGoogle = async () => {
try {
const result = await Google.logInAsync({
androidClientId:ID,
iosClientId:ID,
scopes: ["profile", "email"],
behavior:'web'
});
if (result.type === "success") {
const { idToken, accessToken } = result;
const credential = GoogleProvider.credential(idToken, accessToken);
Firebase
.auth()
.signInWithCredential(credential)
.then(function(result){
if(result.additionalUserInfo.isNewUser){
Firebase.database().ref('UserToQuestion/' + Firebase.auth().currentUser.uid).set({
notifier: {
Email:Firebase.auth().currentUser.email
}
})
}
})
.catch(error => {
Alert.alert(error)
console.log("firebase cred err:", error);
});
} else {
return { cancelled: true };
}
} catch (err) {
console.log("err:", err);
}
}

这是我的安卓应用程序.json

"android": {
"package": "com.aparson.SFS",
"versionCode": 1
},

在谷歌控制台中,我有一个有效的服务帐户,但我没有配置 OAuth 同意屏幕,但我不确定这是否是问题所在,因为当我单击谷歌登录按钮时,什么也没发生。我还将 SHA-1 证书更改为应用程序签名显示的内容,这是某人在不同问题中所说的,但这也没有用。

如果有人能帮忙,我将不胜感激。 谢谢

你应该使用expo-google-sign-in

expo-google-sign-in独立的世博会应用程序或裸 React Native 应用程序提供原生 Google 身份验证。它不能在 Expo 客户端中使用,因为本机GoogleSignIn库在构建时需要info.plist中的REVERSE_CLIENT_ID。要在世博会客户端中使用 Google 身份验证,请查看expo-google-app-authexpo-app-auth

https://docs.expo.io/versions/latest/sdk/google-sign-in/#googleidentity

最新更新