I want to open a specific chat in WhatsApp on clicking a chat bubble in my ionic-angular application. The functionality works fine in iOS if WhatsApp is installed. It will redirect to your WhatsApp application and opens the chat with number specified in this url “https://api.whatsapp.com/send?phone=” + this.whatsAppNo + “&text=”. But if there is no WhatsApp it will open up your default browser ie Safari in iOS and then a pop up comes showing “Safari cannot open the page because the address is invalid”.
.Menu.html
<ion-fab left middle class="whatsapp-share1">
<a ion-fab color="gold" href="#" (click)="clickChat()"
><ion-icon
name="chatbubbles"
ios="ios-chatbubbles"
md="md-chatbubbles"
></ion-icon
></a>
</ion-fab>
Menu.ts
clickChat() {
let url =
"https://api.whatsapp.com/send?phone=" + this.whatsAppNo + "&text=";
console.log("showUrl", url);
this.inAppBrowser.create(url, "_system");
}
Another problem I found is if we try to open that url as a web view inside the application, then it won’t redirect to the WhatsApp application