ios - 为什么当应用程序关闭时,react-navigation 不能从深层链接打开正确的 url?
问题描述
我有一个深度链接配置设置,可以在设备上单击 URL 时打开特定页面。当应用程序在后台打开时,这工作正常,但如果应用程序关闭,它只会打开应用程序而不导航。
这是我的链接配置:
const linking = {
prefixes: ["appname://"],
config: deepLinkRouting,
getStateFromPath(path:string, options:any) {
//build custom params
},
async getInitialURL() {
// Check if app was opened from a deep link
const url = await Linking.getInitialURL();
if (url != null) {
return url;
}
},
subscribe(listener) {
const onReceiveURL = ({ url }) => listener(url);
Linking.addEventListener('url', onReceiveURL);
return () => {
// Clean up the event listener
Linking.removeEventListener('url', onReceiveURL);
};
},
}
这个链接对象是作为道具提供给我的<NavigationContainer/>
我正在使用npx uri-scheme open
命令在模拟器上对此进行测试。我注意到当您关闭应用程序并重新打开它时,应用程序会重新构建,所以我想知道这是否会使测试无效。任何帮助表示赞赏!
解决方案
推荐阅读
- elasticsearch - 精确子串匹配 | 弹性搜索
- java - 创建一个构造函数,将参数中的值复制到一个名为 data 的数组中
- java - 需要自定义arraylist值如下
- hdfs - CAP 定理如何应用于 HDFS?
- javascript - JavaScript:导入模块或向“文档”添加功能?
- javascript - javascript中不同类型的执行
- php - 当我 DD 我的请求时,Laravel Form post to url 不显示任何内容
- c# - 在 WPF 上下文菜单中使用 cal:Message.Attach 时出现“未找到目标方法”错误
- sql - 有没有办法从字符串文字中提取时间
- pointers - SAMD21 - 指针取消引用硬故障,调试器显示有效对象