[英]expo-auth-session with Google login problems in Development build on android
Loggin in with expo-auth-session works absolutely fine in Expo Go App but as soon as.apk is built, the login workflow opens the signin page and then closes after the login is complete but the response vanishes and does not do anything, this happens only in.apk but works fine in Expo Go App.使用 expo-auth-session 登录在 Expo Go 应用程序中工作得非常好,但是一旦构建了.apk,登录工作流程就会打开登录页面,然后在登录完成后关闭,但响应消失并且不执行任何操作,这仅在.apk 中发生,但在 Expo Go 应用程序中工作正常。
const config = {
expoClientId: "some value",
iosClientId: "some value",
androidClientId: "some value",
};
const [user, setUser] = useState(null);
const [request, response, googlePromptLogin] = Google.useAuthRequest(config);
useEffect(() => {
if (response?.type === "success") {
async function SignIn() {
const credential = GoogleAuthProvider.credential(
null,
response.authentication.accessToken
);
await signInWithCredential(auth, credential);
}
SignIn();
}
else {
console.log("not logged in");
}
}, [response]);
useEffect(() => {
onAuthStateChanged(auth, (user) => {
if (user) {
setUser(user);
} else {
setUser(null);
}
});
}),
[];
// Button
<Button onPress={googlePromptLogin} title="Login"/>
You could try setting the "scheme" property in your app.json file.您可以尝试在 app.json 文件中设置“方案”属性。 The schema must be the same as the assigned "package" name for Android.
架构必须与为 Android 分配的“包”名称相同。 That worked for me.
这对我有用。
{
"expo": {
"name": "NewApp",
"scheme": "com.myname.mycoolapp",
"android": {
"package": "com.myname.mycoolapp",
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.