如何从 React Native Linking 打开 Facebook 应用程序(到特定页面)?

How can I open the Facebook App (to a specific page) from React Native Linking?

Linking.openURL('https://www.facebook.com/walmart')
Linking.openURL('fb://profile/walmart');
Linking.openURL('fb://page/walmart');
Linking.openURL('fb://facewebmodal/f?href=walmart')
Linking.openURL('https://www.facebook.com/n/?walmart');

我已经尝试了所有这些,但都是打开网页而不是应用程序。 fb:// 打开应用程序,但没有转到特定页面。

React-native 0.61.1

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fb</string>
        <string>instagram</string>
        <string>twitter</string>
        <string>whatsapp</string>
        <string>linkedin</string>
        <string>fbapi20130214</string>
        <string>fbapi20130410</string>
        <string>fbapi20130702</string>
        <string>fbapi20131010</string>
        <string>fbapi20131219</string>    
        <string>fbapi20140410</string>
        <string>fbapi20140116</string>
        <string>fbapi20150313</string>
        <string>fbapi20150629</string>
        <string>fbapi20160328</string> 
        <string>fbauth</string>
        <string>fbauth2</string>
        <string>fb-messenger-api20140430</string>
    </array>

为了在 Facebook 应用程序中打开特定的 Facebook 页面,您需要拥有唯一标识符 (PAGEID)。

如何获取PAGEID?

选项 1: 使用一些第三方服务,例如:https://findmyfbid.com/。在这里你可以直接进入facebookurl的页面。

选项 2: 在浏览器中打开页面的 facebook url,右键单击个人资料图片,然后按 COPY LINK ADDRESS

Walmart 的头像地址是:

www.facebook.com/159616034235/photos/10157225802004236/ PAGEID 突出显示。

如何在FB App打开页面?

在 iOS 设备上:fb://profile/PAGEID

在 Android 设备上:fb://page/PAGEID

代码示例:

const pageID = 159616034235; // Waltmart's ID 
const scheme = Platform.select({ ios: 'fb://profile/', android: 'fb://page/' });

const url = `${scheme}${pageID}`;

然后你可以使用:

Linking.openURL(url);