facebook - 如何在 React Native 中使用 Facebook Messenger 对话框?

标签 facebook react-native facebook-messenger react-native-fbsdk

我正在使用 react-native-fbsdk 在我的 React Native 项目中使用 Facebook API。我能够使用它实现登录/共享/注销功能,但直到现在还没有找到任何方法来使用 Facebook Messenger 发送对话框。 有什么方法可以使用它在 React Native 项目中集成 FB Messenger 发送对话框吗?

最佳答案

对我来说,这会打开 Messenger 发送对话框(至少在 iOS 上):

const FBSDK = require('react-native-fbsdk');
const {
  MessageDialog
} = FBSDK; 
........
........
........
const shareLinkContent = {
  contentType: 'link',
  contentUrl: 'http://xxxx',
  //contentDescription: 'DONT USE ITS AGAINST FB POLICY',
};

MessageDialog.canShow(shareLinkContent).then(
  function(canShow) {
      if (canShow) {
        return MessageDialog.show(shareLinkContent);
      } else {
        alert('Messenger not installed')
      }
    }
  ).then(
    function(result) {
      if (result.isCancelled) {
        // cancelled
      } else {
        // success
      }
    },
    function(error) {
      showToast('Share fail with error: ' + error, 'error');
    }
  );

希望对你有帮助!

关于facebook - 如何在 React Native 中使用 Facebook Messenger 对话框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40864824/

相关文章:

reactjs - 组件挂载前如何获取数据?

facebook - 用户单击“SEND-TO-MESSENGER”按钮后如何获取 PSID?

javascript - Node.js MongoDB 插入错误

facebook - 将 Facebook Android SDK .aar 文件转换为 Java 库项目

android - Facebook 分享小姐 EXTRAS

使用共享 SSL 的 Facebook 页面选项卡

javascript - 如何在聚焦时摆脱 React Native Paper TextInput 的底部边框

android - React native——我应该使用异步存储还是 cookie?

ios - 操作无法完成。 (com.facebook.sdk.core 错误 3.)

c# - Facebook 的持久菜单回发没有击中 Controller