[英]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.