首页 > 解决方案 > 来自 ShareDialog 的 react-native postId null

问题描述

我过去常常react-native-fbsdk {ShareDialog}在 Facebook 上发布我的提要,但ShareDialog没有返回帖子 ID,在我的情况下它始终为空。

在此处输入图像描述

我的进口

import { ShareDialog, LoginManager, AccessToken, LoginButton } from "react-native-fbsdk";

这是我的代码

const shareLinkContent = {
  contentType: 'link',
  contentUrl: 'https://www.niofox.com/',
  contentDescription: 'Test Sharing Description'
};
var tmp = this;
ShareDialog.canShow(shareLinkContent).then(
  (canShow) => {
    if (canShow) {
      return ShareDialog.show(shareLinkContent);
    }
  }
).then(
  (result) => {
    if (result.isCancelled) {
      alert('Share cancelled');
    } else {
      alert('Share success with postId: ' + JSON.stringify(result));
    }
  },
  (error) => {
    alert('Share fail with error: ' + error);
  }
);

标签: react-native-fbsdkfbsdksharedialog

解决方案


推荐阅读