React native 无法在React本机共享中共享产品的映像
我正在使用react native share共享产品描述、url和图像。但是,它不工作并将附件显示为somename.null。 我从response中获取base64映像。代码写在下面React native 无法在React本机共享中共享产品的映像,react-native,React Native,我正在使用react native share共享产品描述、url和图像。但是,它不工作并将附件显示为somename.null。 我从response中获取base64映像。代码写在下面 shareProduct = () => { console.log(this.props.productDetails); let { name, product_url, base64 } = this.props.productDetails; const shareOp
shareProduct = () => {
console.log(this.props.productDetails);
let { name, product_url, base64 } = this.props.productDetails;
const shareOptions = {
title: "Testing APP",
url: product_url,
message: "This is the testing. Please check",
subject: name
};
if( base64 !== "" && base64 !== undefined ){
shareOptions.url = base64;
shareOptions.type = 'image/jpeg';
}
Share.open(shareOptions)
.then(res => {})
.catch(err => {
console.log(err);
});
};
请帮我找出我错的地方
您需要在选项中更改url:
Share.open(
{
消息:“这是测试,请检查”,
标题:“股份”,
url:product_url,
键入:“image/jpg”,
activityItemSources:[
{
链接元数据:{image:`data:image/jpg;base64,${product\u url}`,
},
],
},
{
//仅限Android:
dialogTitle:“共享”,
//仅限iOS:
excludedActivityTypes:['com.apple.UIKit.activity.posttowitter'],
},
);代码>您需要在选项中更改url:
Share.open(
{
消息:“这是测试,请检查”,
标题:“股份”,
url:product_url,
键入:“image/jpg”,
activityItemSources:[
{
链接元数据:{image:`data:image/jpg;base64,${product\u url}`,
},
],
},
{
//仅限Android:
dialogTitle:“共享”,
//仅限iOS:
excludedActivityTypes:['com.apple.UIKit.activity.posttowitter'],
},
);
在shareOptions.url
中,您是在共享图像的实际url还是Base64?@Rajan是的,我在API调用后得到响应,在API调用中我得到jpg格式的Base64图像,然后在共享选项中传递它。这不是图像url,而是Base64格式。在shareOptions.url
中,您是在共享图像的实际url还是Base64?@Rajan是的,我在API调用后得到响应,其中我得到jpg格式的Base64图像,然后在共享选项中传递它。这不是图像url,而是Base64格式。上面的代码不起作用。我以前试过。上面的代码不起作用。我以前试过。