【发布时间】: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