javascript - React-Native 将应用链接到 Facebook Messenger

标签 javascript react-native deep-linking

例如,我知道我可以深度链接 map ,我用过它并且效果很好。但是 FB Messenger 怎么样?我有一个按钮,当用户单击时我希望它打开 Messenger 并与某人对话。我该怎么做?我尝试直接链接,但它不起作用。

  openMessenger() {
    Linking.canOpenURL('https://www.messenger.com/t/name').then(supported => {
        if (supported) {
            Linking.openURL('https://www.messenger.com/t/name');
        } else {
            console.log('erro');
        }
    }).catch(err => console.error('An error occurred', err));
  }

也试过 fb-messenger://user-thread/{user-id} 还是不行。

顺便说一句,有没有办法询问用户他想用哪个应用程序打开?对于 map ,当我单击按钮时,它会在 iOS 上的 Apple Maps 上打开,但我希望它询问要打开哪个应用程序,因为我不使用 Apple Maps。

最佳答案

Linking.canOpenURL('fb-messenger://').then(supported => {
    if (!supported) {
       console.log('Can\'t handle url: ' + url);
    } else {
       Linking.openURL("fb-messenger://user-thread/" + "facebook id");
    }
}).catch(err => console.log(err)));

iOS

As of iOS 9, your app needs to provide the LSApplicationQueriesSchemes key inside Info.plist or canOpenURL will always return false.

设置 LSApplicationQueriesSchemes => 重启服务器

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fb-messenger-share-api</string>
    <string>fbauth2</string>
    <string>fbshareextension</string>
    <string>fb-messenger</string>
</array>

enter image description here

安卓

To support deep linking on Android, refer http://developer.android.com/training/app-indexing/deep-linking.html#handling-intents

关于javascript - React-Native 将应用链接到 Facebook Messenger,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44548911/

相关文章:

javascript - 在 get 函数中绑定(bind)一个 Promise return

javascript - 如何修复 VUEX 中的状态变化?

ios - Firebase 可以离线使用 React Native 吗?

android - 找不到 com.mapbox.mapboxsdk :mapbox-android-accounts:0. 7.0。全新安装 MapBox

ios - AppsFlyer Onelink 深度链接调试

javascript - html,在等待图像时使页面显示就绪(没有标签旋转轮)

javascript - PHPExcel 搜索/返回单元格中包含特定值的所有行

javascript - react native : Inline image with text

ios - 如何使用深层链接重定向到 Apple App Store? (例如查询字符串)

javascript - 自动将用户重定向到 Chrome 中的深层链接不起作用