当我在 react native 上使用深度链接 android 时遇到问题。当应用程序被深层链接触发时,应用程序处于前台状态时,应用程序不会在该屏幕上刷新。例如,我想要深度链接到主屏幕,但是当我的前景在个人资料屏幕上时,我的应用程序不会刷新?
这是我的深度链接代码:
async componentDidMount() {
// This for deeplinking
if (Platform.OS === 'android') {
Linking.getInitialURL().then(url => {
this.navigate(url);
});
} else {
Linking.addEventListener('url', this.handleOpenURL);
}
navigate = (url) => {
const { navigate } = this.props.navigation;
const route = url.replace(/.*?:\/\//g, '');
const id = route.match(/\/([^\/]+)\/?$/)[1];
const routeName = route.split('/')[0];
if (id === 'yes') {
alert(id)
}
}
最佳答案
我们可以使用 react native firebase 的属性,它可以检测前台、后台或应用程序中的应用程序。 documentation如果您为您的应用使用了通知。如果你没有,你可以使用 做焦点() 从 react 导航。
关于android - 如何在前台刷新原生 Deeplink 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59463531/