Home > Software design >  Ionic 5 socialSharing.shareViaWhatsAppToPhone not attaching image
Ionic 5 socialSharing.shareViaWhatsAppToPhone not attaching image

Time:02-03

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: enter image description here

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);
  });
  •  Tags:  
  • Related