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

TIM*_*MEX 4 linker deep-linking react-native

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');
Run Code Online (Sandbox Code Playgroud)

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

反应原生 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>
Run Code Online (Sandbox Code Playgroud)

Tim*_*Tim 8

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

如何获取PAGEID?

选项 1: 使用一些第三方服务,例如:https : //findmyfbid.com/。在这里,您只需输入页面的 Facebook 网址即可。

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

沃尔玛的头像地址是:

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}`;
Run Code Online (Sandbox Code Playgroud)

然后你可以使用:

Linking.openURL(url);
Run Code Online (Sandbox Code Playgroud)