我在 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 看起来像:“data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...”
任何帮助将不胜感激。
谢谢