gpt4 book ai didi

facebook - 与 react-native-fbsdk 共享图像?

转载 作者:行者123 更新时间:2023-11-30 05:30:00 24 4
gpt4 key购买 nike

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

我有以下内容,几乎完全从文档中复制,但我不知道如何格式化 imageUrl,我不断收到错误消息说 SharingContent 无效

我在这里做错了什么?

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

最佳答案

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

另请注意,您需要安装 Facebook 应用程序才能分享图片。

关于facebook - 与 react-native-fbsdk 共享图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37061266/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com