DEV Community

Irene wanja
Irene wanja

Posted on

Sharing link on WhatsApp from mobile website (not application) for Android

I have developed a website which is mainly used in mobile phones.
I want to allow users to share information directly from the web page into WhatsApp.

Using UserAgent detection I can distinguish between Android and iOS.
I was able to discover that in order to implement the above in iOS I can use the URL:

href="whatsapp://send?text=http://www.example.com"
I'm still looking for the solution to be used when the OS is Android (as the above doesn't work).
I guess it is somehow related to using "intent" in Android, but I couldn't figure out how to do it as parameter for href.
Here is my site gbwa.download I have developed.

Top comments (1)

Collapse
 
kilts_formen_4fb652714a7 profile image
Kilts For Men

For Android, you can use the following URL format to allow users to share information directly from the web page into WhatsApp:

href="intent://send?text=YourTextHere&phone=PhoneNumberWithCountryCode#Intent;scheme=whatsapp;package=com.whatsapp;action=android.intent.action.SENDTO;end"

Replace "YourTextHere" with the text you want to share, and "PhoneNumberWithCountryCode" with the phone number of the person or group you want to share the text with.

Make sure to URL encode the text and phone number parameters, and include the country code for the phone number (e.g. +1 for the United States).

Also, make sure to include the WhatsApp package name ("gb whatsapp apk") and the action to send the text ("android.intent.action.SENDTO") in the URL.

Here's an example of how the URL might look:

href="intent://send?text=Check out my website at http%3A%2F%2Fwww.example.com&phone=%2B1234567890#Intent;scheme=whatsapp;package=com.whatsapp;action=android.intent.action.SENDTO;end"

Some comments may only be visible to logged-in visitors. Sign in to view all comments.