简体   繁体   中英

Ionic 5 socialSharing.shareViaWhatsAppToPhone not attaching image

I am using Social Sharing plugin in Ionic 5 and having issues in sharing image via whatsApp. If I share image via "shareViewWhatsApp" then everything works fine. 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.

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. Ref: https://github.com/tsayen/dom-to-image

dataUrl looks like: "data:image/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在此处输入图像描述

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);
  });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM