[英]Ionic 5 socialSharing.shareViaWhatsAppToPhone not attaching image
我在 Ionic 5 中使用社交共享插件,並且在通過 WhatsApp 共享圖像時遇到問題。 如果我通過“shareViewWhatsApp”共享圖像,那么一切正常。 選擇聯系人后,它會顯示我正在共享的圖像。
但是,如果我使用“shareViaWhatsAppToPhone”或“shareViaWhatsAppToReceiver”直接分享圖片whatsapp聯系人,那么它似乎會忽略圖片而只分享短信。
var node = document.getElementById('body') ;
domtoimage.toPng(node)
.then((dataUrl) => {
this.socialSharing.shareViaWhatsAppToPhone('+61xxxxxxxxx','share toPhone', dataUrl,null).then((res) => {
console.log('image shared with whatsapp');
}).catch((e) => {
console.error('social share, something went wrong!', e);
});
})
.catch((error) => {
console.error('oops, something went wrong!', error);
});
“domtoimage.toPng()”只是一個將Dom節點轉換為圖像的插件。 參考: https://github.com/tsayen/dom-to-image
dataUrl 看起來像:“數據:圖像/png;base64,iVBORw0KGgoAAAANSUhEUg...”
任何幫助將不勝感激。
謝謝
嗨,我早些時候遇到了同樣的問題,后來我在這個文檔中發現( https://www.npmjs.com/package/cordova-plugin-x-socialsharing )它清楚地提到文件在 android 中被忽略,同時直接發送到號碼
所以你可以嘗試類似的東西
this.socialSharing.shareViaWhatsApp('share toPhone', dataUrl,null).then((res) => {
console.log('image shared with whatsapp');
}).catch((e) => {
console.error('social share, something went wrong!', e);
});
})
.catch((error) => {
console.error('oops, something went wrong!', error);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.