[英]Ionic 5 socialSharing.shareViaWhatsAppToPhone not attaching image
I am using Social Sharing plugin in Ionic 5 and having issues in sharing image via whatsApp.我在 Ionic 5 中使用社交共享插件,并且在通过 WhatsApp 共享图像时遇到问题。 If I share image via "shareViewWhatsApp" then everything works fine.如果我通过“shareViewWhatsApp”共享图像,那么一切正常。 After selecting contact it shows image that I am sharing.选择联系人后,它会显示我正在共享的图像。
But if I use "shareViaWhatsAppToPhone" or "shareViaWhatsAppToReceiver" to share image whatsapp contact directly then it seems to ignore the image and only shares text message.但是,如果我使用“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()" is just a plug in to convert Dom node to image. “domtoimage.toPng()”只是一个将Dom节点转换为图像的插件。 Ref: https://github.com/tsayen/dom-to-image参考: https://github.com/tsayen/dom-to-image
dataUrl looks like: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg..." dataUrl 看起来像:“数据:图像/png;base64,iVBORw0KGgoAAAANSUhEUg...”
Any help would be much appriciated.任何帮助将不胜感激。
Thanks谢谢
Hi i had the same issue earlier later i found out in this documentation( https://www.npmjs.com/package/cordova-plugin-x-socialsharing ) it is clearly mentions files are ignored in android while sending directly to number嗨,我早些时候遇到了同样的问题,后来我在这个文档中发现( https://www.npmjs.com/package/cordova-plugin-x-socialsharing )它清楚地提到文件在 android 中被忽略,同时直接发送到号码
so u can try something like所以你可以尝试类似的东西
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.