[英]Ionic Cordova Social Share plugin - cannot read property 'socialsharing' of undefined
[英]How to share an array of image file links or multiple images through socialsharing plugin in ionic?
我正在尝试通过 ionicv4 中的社交共享插件共享一系列动态创建的图像文件链接。 现在我正在用 WhatsApp 测试它。 但它给了我一个 TS 错误,无法在类型字符串中传递 arr[] 。 我确实理解这个错误,但需要一个解决方案。 我做过类似的事情
this.socialSharing.shareViaWhatsApp(null, imageArr , null);
我认为第二个参数应该是一个字符串,你的 imageArr 变量是一个数组。 尝试传递一个字符串
你能尝试创建一个像
const ArrayLikeImages = ('yourImage1', 'yourImage2', 'yourImage3') => arguments;
然后线
this.socialSharing.shareViaWhatsApp(null, ArrayLikeImages , null);
在异步中使用 forloop
const imageurls = [arrayofImageLinks];
let array = [];
for (var _i = 0; _i < imageurls.length; _i++) {
const url = imageurls[_i];
this.http.get(url, {
responseType: ResponseContentType.Blob
})
.toPromise()
.then(async (res: any) => {
const imgBlob = new Blob([res._body], {
type: res.headers.get("Content-Type")
});
var reader = new FileReader();
reader.readAsDataURL(imgBlob);
reader.onloadend = async () => {
const base64data = reader.result;
array.push(base64data);
};
})
.catch(err => {
console.log(err)
});
}
this.socialSharing.shareViaWhatsApp("Title", "", array).then(() => {
//do something when done
}).catch(err => {
// Error Occured
console.log(err);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.