是否可以将用户从 Chrome 自定义选项卡重定向回 Android 应用程序?

问题描述 投票:0回答:1

我希望将现有的社交登录重定向 URL 从自定义 URL 协议 (

myscheme://
) 迁移到 https URL 方案 (
https://
)。此更改将在 React Native 项目中进行,但仅限于 Android 应用程序。我正在考虑使用
expo-web-browser
,它使用 Chrome 自定义选项卡来实现 Android 功能。

实际上,我遇到的是更新后的

https://
重定向 URL 在
expo-web-browser
中正确打开,但
openAuthSessionAsync
承诺未正确解析(并且浏览器窗口未关闭)。如果我在默认 Chrome 浏览器中打开社交登录链接,相同的流程会按预期工作,但系统会提示用户选择是在应用程序还是浏览器中打开该链接(流程中的一个不需要的步骤)。我很好奇这是否是
expo-web-browser
或自定义选项卡的限制,或者我的设置中是否缺少某些内容。

// this is how I make the call to openAuthSessionAsync (opens a Chrome Custom Tab)
WebBrowser.openAuthSessionAsync('social-login-url', 'https://foo.bar/xxx', {
  preferEphemeralSession: true, // iOS only
});

// this is the intent-filter in the AndroidManifest.xml file
<intent-filter android:autoVerify="true">
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <category android:name="android.intent.category.BROWSABLE" />
  <data android:scheme="https" android:host="foo.bar" android:path="/xxx" />
</intent-filter>

我尝试过使用

expo-web-browser
react-native-inappbrowser-reborn
,这让我觉得我要么没有在
AndroidManifest
文件中正确设置某些内容,要么自定义选项卡根本不支持此行为。

期望的是,如果我提供

https://

 重定向到我的身份验证流程,自定义选项卡将被关闭,并且在身份验证完成时用户将被重定向到相应的深层链接。实际结果是用户返回到自定义选项卡中的 
https://
 URL,进而呈现 Web 应用程序。

android react-native expo chrome-custom-tabs
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.