EddyVerbruggen / SocialSharing-PhoneGap-Plugin

👨‍❤️‍💋‍👨 Cordova plugin to share text, a file (image/PDF/..), or a URL (or all three) via the native sharing widget
MIT License
1.78k stars 905 forks source link

shareViaWhatsAppToReceiver #1167

Open ademir10 opened 2 years ago

ademir10 commented 2 years ago

Hi guys! i'm trying to share the screenshot to specific receiver but no way.. Do you know if i need to do something more?

this is my code: ShareWhatsapp(){ this.socialSharing.shareViaWhatsAppToReceiver(this.whatsapp_number, this.text, this.screen, this.url) }

When i try to use shareViaWhatsApp without Receiver everything works fine. any suggestion?

bmunjal commented 2 years ago

I will recommend - https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share

bborad commented 2 years ago

That article didn't make much sens to me. If I am shareing base64 image, do I still need to check "canShare"? I am getting base64 image via domToImage pulgin that I want to send to a whatsapp number llike

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

As @ademir10 said, this all works fine with "socialSharing.shareViaWhatsApp" for me as well. But with ToPhone or ToReceiver its just not attaching image. Text message works fine though.