'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



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source