我正在通过Gmail应用程序(Android)中的电子邮件打开应用程序的重置密码屏幕。如果我在Gmail常规设置中选中“在Gmail中打开Web链接”设置,则电子邮件中的链接不会重定向到正确的屏幕。但是,如果我取消上述设置,它就可以正常工作。
这是在我的初始屏幕中
componentDidMount() {
Linking.addEventListener('url', this.handleUrl);
Linking.getInitialURL().then((ev) => {
//ev is null in above case
if (ev) {
this.handleUrl(ev);
}
}).catch(err => {
console.warn('An error occurred', err);
});
}
handleUrl = (url) => {
const eveUrl = this.evaluateUrl(url);
Linking.canOpenURL(eveUrl).then((supported) => {
if(supported) {
this.addRoutesToDeepLinking(eveUrl); //navigate to correct screen
}
})
}
这在使用Gmail应用程序的iOS上完全可以正常运行,并且在其他Outlook安卓系统的电子邮件客户端中也可以正常运行。 (我正在使用Firebase动态链接)
AndroidManfest.xml>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="xxx.page.link" android:scheme="https"/>
</intent-filter>
然后
android:launchMode="singleTask"