我有一个用native native代码编写的应用程序。我有这个功能的组件:
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,我登录然后服务器成功返回redirect_uri和app隐藏webapp模式并显示我需要的东西。
但是,当我将应用程序导出到Android并在我的手机中安装此apk时,它仍然完美,点击打开webview,我以用户身份登录并返回。但它保持步骤“返回应用程序”。它永远不会回到应用程序。我也在app.json中定义了schema:
{
"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://')
以用作我定义的模式,但也没有成功。