gpt4 book ai didi

react-native - react 导航 v5 : How to use with Branch. io

转载 作者:行者123 更新时间:2023-12-02 02:34:22 34 4
gpt4 key购买 nike

我们有一个使用 Branch.io 通用链接的应用程序。遵循以下文档: https://help.branch.io/developers-hub/docs/react-native#read-deep-link

在 react-native 应用程序上,您设置订阅者以在 javascript 运行时接收深度和通用链接。

从这里使用最新的 react-navigation:https://reactnavigation.org/docs/deep-linking

React Navigation 希望原生处理深度链接。 React Navigation 似乎没有提供手动启动链接的好方法。

如何同时使用这两项服务?采用深层链接并将其分解为可路由的深层链接被证明具有挑战性。我们的应用程序有嵌套的路由器,重做从路径到屏幕和参数的转换是我不想做的事情。最近有没有人做过这个?谢谢。

最佳答案

您可以使用 subscribe 选项通知 React Navigation 有关传入链接的信息:

const linking = {
// Custom susbcription to handle incoming links
subscribe(listener) {
branch.subscribe(({ error, params, uri }) => {
if (error) {
console.error('Error from Branch: ' + error);
return;
}

if (params['+non_branch_link']) {
const nonBranchUrl = params['+non_branch_link'];
// Route non-Branch URL if appropriate.
return;
}

if (!params['+clicked_branch_link']) {
// Indicates initialization success and some other conditions.
// No link was opened.
return;
}

// A Branch link was opened
const url = params.$canonical_url;

listener(url);
});

return () => {
// Clean up the event listeners
branch.unsubscribe();
};
},
// Options such as prefixes, screens config etc.
// ...
};

文档:https://reactnavigation.org/docs/deep-linking/#third-party-integrations

关于react-native - react 导航 v5 : How to use with Branch. io,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64545934/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com