Expo auth在生产构建中不工作,在开发构建中工作良好



我的博览会权限不工作时,我发布到博览会,当我下载它时,它只显示谷歌提示和重定向,什么也不做,不更新认证令牌,也不获取任何数据。但是它在开发构建中工作得非常好

` const [accessToken, setAccessToken] = useState();
const [userInfo, setUserInfo] = useState();
const [auth, setAuth] = useState();
const [request, response, promptAsync] = Google.useAuthRequest({
androidClientId:
"xyc",
iosClientId:
"xyc",
expoClientId:
"xyc",
});
useEffect(() => {
if (response?.type === "success") {
setAccessToken(response.authentication);
const persistAuth = async () => {
await AsyncStorage.setItem(
"auth",
JSON.stringify(response.authentication)
);
};
persistAuth();
}
}, [response]);
useEffect(() => {
const getPersistedAuth = async () => {
const jsonValue = await AsyncStorage.getItem("auth");
if (jsonValue != null) {
const authFromJson = JSON.parse(jsonValue);
setAuth(authFromJson);
let userInfoResponse = await fetch(
"https://www.googleapis.com/userinfo/v2/me",
{
headers: { Authorization: `Bearer ${authFromJson.accessToken}` },
}
);
userInfoResponse.json().then((data) => {
setUserInfo(data);
});
setRequireRefresh(
!AuthSession.TokenResponse.isTokenFresh({
expiresIn: authFromJson.expiresIn,
issuedAt: authFromJson.issuedAt,
})
);
}
};
getPersistedAuth();
}, [response]);`

我尝试在app.json中更新我的方案这是我的app.json。

{
"expo": {
"name": "deliveroo",
"slug": "deliveroo",
"version": "1.2.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"scheme": "com.hammadsohaill786.project",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0,
"url": "xyc"
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.hammadsohaill786.project"
},
"android": {
"googleServicesFile": "./google-services.json",
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
},
"package": "com.hammadsohaill786.deliveroo"
},
"web": {
"favicon": "./assets/favicon.png"
},
"extra": {
"eas": {
"projectId": "xyc"
}
},
"plugins": [
"@react-native-google-signin/google-signin"
],
"runtimeVersion": {
"policy": "sdkVersion"
}
}
}

FIXED*

任何有类似问题的人,确保将代理设置为false (promptAsync({useProxy: false, showInRecents: true})),注意它可能不适用于您的开发Expo GO应用程序,但它将适用于您的EAS构建,这是问题对吗?

<TouchableOpacity
className="bg-[#00CCBB] text-white py-1 px-3 items-center justify-center rounded-xl"
onPress={
auth
? logout
: () => promptAsync({ useProxy: false, showInRecents: true })
}
title={auth ? "Logout" : "login"}
>
<Text
className={`${
auth ? "text-black font-bold" : "text-white font-bold"
}`}
>
{auth ? "Logout" : "login"}
</Text>
</TouchableOpacity>

相关内容

最新更新