如何使用Facebook messenger对话框进行本地反应?

时间:2016-11-29 11:30:11

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

我正在使用react-native-fbsdk在我的本机项目中使用Facebook API。我能够使用这个实现登录/共享/注销功能,但到目前为止还没有找到任何方式使用Facebook Messenger发送对话框。 有没有什么办法可以在反应本机项目中使用它来集成FB messenger发送对话框?

1 个答案:

答案 0 :(得分:0)

对我来说,这会打开信使发送对话框(至少在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');
    }
  );

希望它可以帮到你!