javascriptandroidwhatsapp

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!


Solution

  • 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))