Ionic native share plugin not working for whatsapp


#1

native share plugin works for email but when I use the share via whatsapp function it doesn’t work…
Can you suggest the code so that share plugin works for whatsapp as well.
I used the code similar to that give in ionic docs…


#2

I have used Social Sharing .
First you have to inject the plugin.

constructor(private socialSharing: SocialSharing) { }

then you have to call the shareViaWhatsApp(message, image, url) function like this:

whatsappShare(){
    this.socialSharing.shareViaWhatsApp("Your Message", "image" , "link")
      .then(()=>{
        console.log("WhatsApp share successful");
      }).catch((err)=> {
      console.log("An error occurred ", err);
    });
  }

then you can call whatsappShare( ) to share.


#3

you better share the code.
I confirm that share plugin works well in my app.


#5


Here is the snippet of the code I used to impliment socialshare plugin.
Can you please help me figuring out where I went wrong.

PS: I repeat Email and twitter are working the plugin is not working for whatsapp and other social media


#6

WHATSAPP IOS9 QUIRK

"If you want to use ‘shareViaWhatsApp’ on iOS9 you need to whitelist the url scheme of whatsapp and test for the app’s availability with canShareVia()"

window.plugins.socialsharing.canShareVia('whatsapp', 'Hi', file, url, [success], [error]);

Source: https://plugins.telerik.com/cordova/plugin/socialsharing


#7

Hi@yash05041999
i have the same issue.using share via whats app function.
but
this.socialSharing.shareViaWhatsApp(‘message’,null,null)
helps to send message,while adding the url and image it shows “sharing failed please try again”


#8

same here;

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.6
    Cordova Platforms  : ios 4.5.4
    Ionic Framework    : ionic-angular 3.9.2

System:

    ios-deploy : 1.9.2
    ios-sim    : 6.1.2
    Node       : v6.9.5
    npm        : 5.3.0
    OS         : macOS High Sierra
    Xcode      : Xcode 9.2 Build version 9C40b

and here is my sharing code

this.share.shareViaWhatsApp(‘message’,’image url’,’shared url').then( () => {
                            
                            const toast = this.toastCtrl.create({
                                message: ’Shared its ok...',
                                position: 'middle',
                                duration: 2000,
                                closeButtonText:’Close',
                                cssClass:'toastcss'
                              });
                          
                              toast.present();
                        }).catch(()=>{
                            const toast = this.toastCtrl.create({
                                message: ’There is an error',
                                position: 'middle',
                                duration: 2000,
                                closeButtonText:’Close',
                                cssClass:'toastcsserror'
                              });
                          
                              toast.present();
                        });

when i test it it shares only images. there is no message and no url.


#9

I am facing the same issue, no url