【发布时间】:2021-08-19 16:58:01
【问题描述】:
我正在我的 react 本机应用程序中实现与 expo 的深度链接。我已经设法使用此代码和this tutorial 和this documentation 来调整它以适应我的嵌套堆栈:
const linking = {
prefixes:[prefix],
config: {
screens: {
Drawer: {
screens: {
Tabs: {
screens: {
Profile:"profile"
}
}
}
},
}
}
}
return (
<NavigationContainer linking={linking}>
<RootStackScreen actions={actions} showLoader={showLoader} user={user} {...props} />
</NavigationContainer>
)
}
如果我使用myscheme://profile,它会按预期工作,但前提是应用程序在后台打开。当应用程序关闭时,它只是在我的初始主屏幕中打开它,我尝试使用谷歌搜索,但找不到任何适合我所做的解释。我还尝试将getInitialRoute 函数添加到linking,当应用程序关闭并从深层链接打开时触发,但不知道如何使用它来激活导航。
async getInitialURL() {
const url = await Linking.getInitialURL(); // This returns the link that was used to open the app
if (url != null) {
//const { path, queryParams } = Linking.parse(url);
//console.log(path,queryParams)
//Linking.openURL(url)
return url;
}
},
【问题讨论】:
标签: react-native navigation expo deep-linking