Dileepa Chandima
Dileepa Chandima

Reputation: 389

FBSDK Share Dialog is not working React-native ios simulator

I'm try to add FBSDK and try to implement Share URL on facebook with the Xcode simulator. But it always return Share operation was cancelled following is my code

const shareLinkContent = {
  contentType: 'link',
   contentUrl: "https://facebook.com",
contentDescription: 'Facebook sharing is easy!',
};

var tmp = this;
ShareDialog.canShow(shareLinkContent).then(

  function(canShow) {
    console.log(canShow)
    if (canShow) {
      return ShareDialog.show(shareLinkContent);
    }
  }
).then(
  function(result) {
    console.log(result)
    if (result.isCancelled) {
      alert('Share operation was cancelled');
    } else {
      alert('Share was successful with postId: '
        + result.postId);
    }
  },
  function(error) {
    alert('Share failed with error: ' + error.message);
  }
);
}

This is the HTML button fro share

<Button
onPress={() => this.shareLinkWithShareDialog()}
title="share"
color="#841584"
accessibilityLabel="Learn more about this purple button"
/>

Upvotes: 1

Views: 714

Answers (1)

Lucky_girl
Lucky_girl

Reputation: 4863

You can't test it on simulator, you need to test this feature on real device, where Facebook app is already installed.

Upvotes: 1

Related Questions