facebookreact-nativefacebook-sharereact-native-fbsdk

Share links via Facebook Messenger - react-native android


I want to share links only via Facebook messenger. I have checked 3 libraries and none of them has what I need:

  1. Share (build-in in react-native): not possible to share links in Android
  2. react-native-share: doesn't support sharing via FB messenger, only via Facebook
  3. react-native-fbsdk: not possible to share via messenger, only via Facebook

How is possible to implement this feature?


Solution

  • Found the solution in react-native-fbsdk, there is possibility to share links via Fb messenger using MessageDialog.

    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);
          }
        );
      }