繁体   English   中英

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

[英]How to use Facebook messenger dialog in react native?

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

希望它能帮到你!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM