React native react native(expo)中的AuthSession不会返回应用程序Android
我有一个用react本地代码编写的应用程序。我有一个具有此功能的组件:React native react native(expo)中的AuthSession不会返回应用程序Android,react-native,expo,React Native,Expo,我有一个用react本地代码编写的应用程序。我有一个具有此功能的组件: handleLogin = async () => { let redirectUrl = AuthSession.getRedirectUrl(); let results = await AuthSession.startAsync({ authUrl: `https://exampleurl.com/?uid=${CLIENT_ID}&redirect_uri=${enco
handleLogin = async () => {
let redirectUrl = AuthSession.getRedirectUrl();
let results = await AuthSession.startAsync({
authUrl: `https://exampleurl.com/?uid=${CLIENT_ID}&redirect_uri=${encodeURIComponent(redirectUrl)}`
});
if (results.type !== 'success') {
this.setState({ didError: true });
} else {
if(results.params.token != undefined) {
let user = {
name: results.params.uname,
surname: results.params.surname,
token: results.params.token
}
this.setState({ userInfo: user});
this.props.loginUser(this.state.userInfo);
}
}
};
问题是,当我在Expo中运行它们时,它工作正常,打开适当的URL,我登录,然后服务器成功返回我重定向uri和应用程序隐藏webapp模式,并显示我需要的内容
但当我将应用程序导出到android并在我的手机上安装这个apk时,它仍然可以完美地工作,单击open webview,我以用户身份登录并返回。但它停留在“返回应用程序”步骤。它永远不会返回应用程序。我还在我的app.json中定义了模式:
{
"expo": {
"name": "MyNewApp",
"slug": "MyNewApp",
"privacy": "public",
"sdkVersion": "32.0.0",
"platforms": [
"ios",
"android"
],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"scheme": "MyNewApp",
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"bundleIdentifier": "com.roche.mynewapp",
"supportsTablet": true
},
"android": {
"package": "com.roche.mynewapp"
}
}
}
我做错了什么?我尝试将重定向uri设置为
encodeURIComponent('MyNewApp://')
以用作我的模式定义,但也没有成功 app.json中的方案必须是您的android.package
名称
因此,在您的案例中,方案:“com.roche.mynewapp”
这对我有用。如需了解更多详细信息,请遵循Expo文档任何解决方案??我删除了Expo,并切换到默认的React Stuff:)即使我至少喜欢这样做:p