【问题标题】:React native Linking open url not working with facebook link on iosReact native Linking open url不适用于ios上的facebook链接
【发布时间】:2021-08-25 06:36:33
【问题描述】:

提前致谢。

我正在尝试使用链接组件打开一个 Facebook 页面/个人资料网址。

我使用了下面的代码。

 Linking.canOpenURL('fb://profile/<PAGE ID or PROFILE ID>').then(supported => {
            if (supported) { 
                return Linking.openURL('fb://profile/<PAGE ID or PROFILE ID>');
            } else { 
                return Linking.openURL('https://facebook.com/XXXXX');
            }
        });

当我在 iOS 中使用上述代码时,它会在浏览器而不是 facebook 应用中打开,即使我的手机中有它。

如果我将相同的代码(if 块)放在 else 部分,我会收到以下错误。

2021-08-25 12:02:14.853723+0530[793:75609] [default] Failed to open URL fb://profile/xxxxxx: Error Domain=NSOSStatusErrorDomain Code=-10814 "(null)" UserInfo={_LSLine=229, _LSFunction=-[_LSDOpenClient openURL:options:completionHandler:]}
2021-08-25 12:02:16.877524+0530[793:71906] [javascript] Possible Unhandled Promise Rejection (id: 1):
Error: Unable to open URL: fb://profile/xxxxxx

我还添加了LSApplicationQueriesSchemes 将 facebook 和 fb 作为 plist 文件中的项目

【问题讨论】:

  • 我还在 plist 文件中添加了带有 facebook 和 fb 的 LSApplicationQueriesSchemes 作为项目

标签: ios react-native deep-linking


【解决方案1】:

经过大量研究,我找到了解决方案。

fb://profile?id=<PAGE_NAME OR PAGE_ID>

即使您尝试打开个人资料或页面,也请使用 fb://profile。 我认为 fb://page 不再存在。

确保将Info.plist 更新为LSApplicationQueriesSchemes

[fb, facebook]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-22
    • 1970-01-01
    • 2021-11-15
    相关资源
    最近更新 更多