Open whatsapp chat for a number ionic 3/4

16,452

Solution 1

This is how it works in 2019 with Ionic 4

In config.xml add:

<access launch-external="yes" origin="whatsapp://*" />

In your html:

<a href="whatsapp://send?phone=YOUR_NUMBER">Link<a>

Solution 2

It's very simple but it has a trick.

<a ion-button href="whatsapp//send?phone=54119998888">SEND</a>

but you have to allow the "whatsapp" in the config.html or it's going to be blocked (by security). So include this:

<access origin="whatsapp//*" launch-external="yes" />

be careful not to include "https://*" because it's not gonna work...

Solution 3

I've searched on the ionic forum's and found this with 15 votes.

By going to this URL "https://api.whatsapp.com/send?phone= 573{The phone number}" for more info - check this : https://faq.whatsapp.com/en/26000030/?category=5245251 540

Share:
16,452

Related videos on Youtube

Ngoni X
Author by

Ngoni X

Updated on June 04, 2022

Comments

  • Ngoni X
    Ngoni X almost 2 years

    I have developed an app that should open a whatsapp chat using this plugin.

    I installed it using ionic CLI ionic cordova plugin add https://github.com/ranjitpandit/whatsapp-phonegap-plugin.git and the used it as below:

    home.page.ts

    ...
    
    declare var cordova;
    
    ...
    constructor(public platform: Platform) {}
    
    chat() {
    
        this.platform.ready().then(() => {
    
          cordova.plugins.Whatsapp.send('+263783187321');
    
        });
    
    }
    

    Then in home.page.html I then did this:

    <ion-row>
        <ion-col size="12" no-padding>
          <img src="assets/imgs/chat.jpg" (click)="chat()" class="chat" />
        </ion-col>
    </ion-row>
    

    The problem is that it's not opening a Whatsapp chat window when I click the image. Nothing happens. Please help. Thank you

  • Ngoni X
    Ngoni X about 5 years
    Here is the solution to my problem. Upon further research I added this to config.xml <access origin="whatsapp:*" launch-external="yes" />
  • Riyad Khalifeh
    Riyad Khalifeh over 4 years
    Perfect Solution!
  • Ari Waisberg
    Ari Waisberg about 4 years
    @Anuj just create a var like let wa = "whatsapp//send?phone=" + client_phone; and then use brackets: <a ion-button [href]="wa">SEND</a>
  • WorldOfEmre
    WorldOfEmre about 3 years
    adding this: <access launch-external="yes" origin="whatsapp://*" /> worked!!
  • Danillo Leão Lopes
    Danillo Leão Lopes about 2 years
    It`s not work here!