通过Facebook Messenger共享链接-React-Native Android

时间:2018-10-11 10:56:41

标签: facebook react-native react-native-android facebook-share react-native-fbsdk

我只想通过Facebook信使共享链接。我已经检查了3个库,但都没有我需要的库:

  1. Share(内置于react-native):无法在Android中共享链接
  2. react-native-share:不支持通过FB Messenger共享,仅通过Facebook
  3. react-native-fbsdk:无法通过Messenger共享,只能通过Facebook

如何实现此功能?

1 个答案:

答案 0 :(得分:0)

在react-native-fbsdk中找到了解决方案,可以使用MessageDialog通过Fb Messenger共享链接。

shareLinkWithShareDialog= () => {
    var tmp = this;
    MessageDialog.canShow(this.state.shareLinkContent).then(
      function(canShow) {
        if (canShow) {
          return MessageDialog.show(tmp.state.shareLinkContent);
        }
      }
    ).then(
      function(result) {
        if (result.isCancelled) {
          console.log('Share cancelled');
        } else {
          console.log('Share success with postId: '
            + result.postId);
        }
      },
      function(error) {
        console.log('Share fail with error: ' + error);
      }
    );
  }