我正在尝试通过react- Native -fbsdk包将图片分享到React native中的Facebook。
我有以下内容,几乎完全是从文档中复制过来的,但我不知道如何格式化imageUrl,我总是收到错误,说是SharingContent is invalid。
我在这里做错了什么?
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);
}
);发布于 2016-06-06 14:07:32
您可以使用react-native- image -picker https://github.com/marcshilling/react-native-image-picker来获取图像的uri,并使用它创建一个SharePhotoContent。
还请注意,您需要安装facebook应用程序才能共享图像。
发布于 2018-02-22 16:29:48
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);
}
);
}https://stackoverflow.com/questions/37061266
复制相似问题