首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >与react-native-fbsdk共享镜像?

与react-native-fbsdk共享镜像?
EN

Stack Overflow用户
提问于 2016-05-06 06:22:17
回答 2查看 4.3K关注 0票数 4

我正在尝试通过react- Native -fbsdk包将图片分享到React native中的Facebook。

我有以下内容,几乎完全是从文档中复制过来的,但我不知道如何格式化imageUrl,我总是收到错误,说是SharingContent is invalid

我在这里做错了什么?

代码语言:javascript
复制
const sharePhotoContent = {
  contentType: 'photo',
  photos: [
    {
      imageUrl: "./local/image/path.png",
      userGenerated: false,
      caption: "Hello World"
    }
  ]
};

ShareDialog.canShow(sharePhotoContent).then(
  function(canShow) {
    if (canShow) {
      return ShareDialog.show(sharePhotoContent);
    }
  }
).then(
  function(result) {
    if (result.isCancelled) {
      AlertIOS.alert('Share cancelled');
    } else {
      AlertIOS.alert('Share success with postId: ' + result.postId);
    }
  },
  function(error) {
    AlertIOS.alert('Share fail with error: ' + error);
  }
);
EN

回答 2

Stack Overflow用户

发布于 2016-06-06 14:07:32

您可以使用react-native- image -picker https://github.com/marcshilling/react-native-image-picker来获取图像的uri,并使用它创建一个SharePhotoContent。

还请注意,您需要安装facebook应用程序才能共享图像。

票数 2
EN

Stack Overflow用户

发布于 2018-02-22 16:29:48

代码语言:javascript
复制
This is working fine for me 

  shareLinkWithShareDialog() {

let shareLinkContent = {

contentType: 'link',

contentUrl: 'https://www.facebook.com/images/fb_icon_325x325.png',

contentDescription: 'Facebook sharing is easy!'
      }

 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: ' + result.postId);

   }

  },

  function(error) {

  alert('Share fail with error: ' + error);
      }
    );
  }
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37061266

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档