我在 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節點轉換為影像的插件。參考:
所以你可以嘗試類似的東西
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);
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/424265.html
