Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

whatsapp://send?text= Doesn't work

I'm developing a hybrid app for android. I've added the following code:

<a href="whatsapp://send data-text=mytext">Send message to WhatsApp</a>
<a href="whatsapp://send?text=Hello%20World!">Hello, world!</a>

However, when I click on those links on my phone, whatsapp doesn't pop-up. Can you, please, help me out? Why isn't that message being shared?

Thanks in advance!

like image 681
Pablo D. Avatar asked Feb 04 '18 16:02

Pablo D.


1 Answers

This is the URL you should use:

https://api.whatsapp.com/send?phone=15551234567&text=I'm%20interested%20in%20your%20car%20for%20sale

In JavaScript, you must encode the text for e.g.

var url='https://api.whatsapp.com/send'
var text='text can contain this char: &'
window.open(url + '?phone=2211227373&text=' encodeURIComponent(text))
like image 186
Aminadav Glickshtein Avatar answered Oct 20 '22 10:10

Aminadav Glickshtein