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

AndroidHtmlMobileShareWhatsapp

Android Problem Overview


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.

Android Solutions


Solution 1 - Android

Just saw it on a website and seems to work on latest Android with latest chrome and whatsapp now too! Give the link a new shot!

<a href="whatsapp://send?text=The text to share!" data-action="share/whatsapp/share">Share via Whatsapp</a>

Rechecked it today (17th April 2015):
Works for me on iOS 8 (iPhone 6, latest versions) Android 5 (Nexus 5, latest versions).

It also works on Windows Phone.

Solution 2 - Android

The above answers are bit outdated. Although those method work, but by using below method, you can share any text to a predefined number. The below method works for android, WhatsApp web, IOS etc.

You just need to use this format:

<a href="https://api.whatsapp.com/send?phone=whatsappphonenumber&text=urlencodedtext"></a>

UPDATE-- Use this from now(Nov-2018)

<a href="https://wa.me/whatsappphonenumber/?text=urlencodedtext"></a>

> Use: https://wa.me/15551234567 > > Don't use: https://wa.me/+001-(555)1234567 > > To create your own link with a pre-filled message that will > automatically appear in the text field of a chat, use > https://wa.me/whatsappphonenumber/?text=urlencodedtext where > whatsappphonenumber is a full phone number in international format and > URL-encodedtext is the URL-encoded pre-filled message. > > Example:https://wa.me/15551234567?text=I'm%20interested%20in%20your%20car%20for%20sale > > To create a link with just a pre-filled message, use > https://wa.me/?text=urlencodedtext > > Example:https://wa.me/?text=I'm%20inquiring%20about%20the%20apartment%20listing > > After clicking on the link, you will be shown a list of contacts you > can send your message to.

For more information, see https://www.whatsapp.com/faq/en/general/26000030

Solution 3 - Android

Currently, it's very easy to achieve this. You only need to add the following code to your pages:

<a href="whatsapp://send?text=<<HERE GOES THE URL ENCODED TEXT YOU WANT TO SHARE>>" data-action="share/whatsapp/share">Share via Whatsapp</a>

And that's it. No Javascript needed, nothing else needed. Of course you can style it as you want and include a nice Whatsapp icon.

I tested this in my Android device with Google Chrome. The versions:

  • Android 4.1.2 (Jelly Bean)
  • Chrome Mobile 37.0.2062.117. Also tested on Firefox Mobile 31.0.
  • Whatsapp V 2.11.399

It also works on iOS. I've made a quick test on an iPhone 5 with Safari and it works as well.

Hope this helps someone. :-)

Solution 4 - Android

According to the new documentation, the link is now:

<a href="https://wa.me/?text=urlencodedtext">Share this</a>

If it doesn't work, try this one :

<a href="whatsapp://send?text=urlencodedtext">Share this</a>

Solution 5 - Android

The official docs say to use: wa.me. Don't use wa.me. I apologize for the length of these results, but it's been a rapidly-evolving issue....

April, 2020 Results

Share Link

>This link is incorrect. Close this window and try a different link.

May, 2020 Results

Share Link GitHub Ticket: WhatsApp short link without phone number not working anymore

>We couldn't find the page you were looking for > >Looks like you're looking for a page that doesn't exist. Or a page we might have just deleted. Either way, go back or be sure to check the url, your spelling and try again.

August, 2020 Results

Share Link

>Works as expected!

LATEST - October, 2020 Results

Share Link

>(Broken again!) og:image tag previews are disabled when using wa.me.

Based on some of the comments I'm seeing, it seems like this still be an intermittent problem, so, going forward, I recommend you stick to the api.whatsapp.com URL!

If you want to share, you must absolutely use one of the two following URL formats:

https://api.whatsapp.com/send?text=YourShareTextHere
https://api.whatsapp.com/send?text=YourShareTextHere&phone=123

If you are interested in watching a project that keeps track of these URLs, then check us out!: https://github.com/bradvin/social-share-urls#whatsapp

Social Share URLs

Solution 6 - Android

Recently WhatsApp updated on its official website that we need to use this HTML tag in order to make it shareable to mobile sites:

<a href="whatsapp://send?text=Hello%20World!">Hello, world!</a>

You can replace text= to have your link or any text content

Solution 7 - Android

LATEST UPDATE

Now you can use the latest API from whatsapp https://wa.me/ without worrying about the user agent, the API will do the user agent handling.

Share pre-filled text with contact selection option in respective whatsapp client (Android / iOS / Webapp):

https://wa.me/?text=urlencodedtext

Open Chat Dialog for a particular whatsapp user in respective whatsapp client (Android / iOS / Webapp):

https://wa.me/whatsappphonenumber

Share pre-filled text with a particular user (Combine above two):

https://wa.me/whatsappphonenumber/?text=urlencodedtext

Note : whatsappphonenumber should be full phone number in international format. Omit any zeroes, brackets or dashes when adding the phone number in international format.

For official documentation visit https://faq.whatsapp.com/en/general/26000030

Solution 8 - Android

I'm afraid that WhatsApp for Android does not currently support to be called from a web browser.

I had the same requirement for my current project, and since I couldn't find any proper information I ended up downloading the APK file.

In Android, if an application wants to be called from a web browser, it needs to define an Activity with the category android.intent.category.BROWSABLE.

You can find more information about this here: https://developers.google.com/chrome/mobile/docs/intents

If you take a look to the WhatsApp AndroidManifest.xml file, the only Activiy with category BROWSABLE is this one:

<activity android:name="com.whatsapp.Conversation"   android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:windowSoftInputMode="stateUnchanged">
        <intent-filter>
            <action android:name="android.intent.action.SENDTO" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="sms" />
            <data android:scheme="smsto" />
        </intent-filter>
    </activity>

I've been playing with it for a while, and I couldn't make it to work. The most I got was to open the WhatsApp application from Chrome, but I couldn't figure out a way to set the message content and recipient.

Since it is not documented by the WhatsApp team, I think this is still work in progress. It looks like in the future WhatsApp will handle SMS too.

The only way to get more information is by reaching the WhatsApp dev team, what I tried, but I'm still waiting for a response.

Regards!

Solution 9 - Android

Just tested the whatsapp:// scheme on my super old Android 2.3.3 with Whats App 2.11.301, works like a charm. It seems to be just the Whats App version. Since Whats App is forcing everyone to update, it should be safe to use it.

The Whats App documentation also mention that scheme: http://www.whatsapp.com/faq/en/android/28000012

I'm using this on a production site now and will update here, if I get any user complaints.

Edit (Nov 14): No user complaints after a couple of weeks.

Solution 10 - Android

In general it makes sense only to display the Whatsapp Link on iOS or Android Devices only, using java script:

   if (navigator.userAgent.match(/iPhone|Android/i)) {
      document.write('<a href="whatsapp://send?text=See..">Share on WhatApp</a>');
   }

Solution 11 - Android

This code worked for me.

After clicking on the link, it will ask you to choose the contact to share a message.

<a href="https://api.whatsapp.com/send?text=enter message here">Click here to share on Whatsapp</a>

You can add target="_blank" attribute to open it in a new window or tab.

I don't think the phone number is needed when someone wants to share a particular message or article.

Solution 12 - Android

Switch the whatsapp share links according to the platform whether desktop or mobile.

This works with or without providing the phone number in the link.

For Mobile

   vm.LinkTextToShare = 'https://api.whatsapp.com/send?text=' + encodeURIComponent(window.location.href) ;
                
   window.open(vm.LinkTextToShare,"_blank");

For Desktop

   vm.LinkTextToShare = 'https://web.whatsapp.com/send?l=en&text=' + encodeURIComponent(window.location.href) ;

   window.open(vm.LinkTextToShare,"_blank");

Solution 13 - Android

use it like "whatsapp://send?text=" + encodeURIComponent(your text goes here), it will definitely work.

Solution 14 - Android

Try to make it this way:

<a href="https://wa.me/(phone)?text=(text URL encoded)">Link</a>

Even you can send messages without enter the phone number in the link:

<a href="https://wa.me/?text=Hello%20world!">Say hello</a>

After clicking on the link, you will be shown a list of contacts you can send your message to.

More info in https://faq.whatsapp.com/en/general/26000030.

Good luck!

Solution 15 - Android

> Use: https://wa.me/1XXXXXXXXXX > > Don't use: https://wa.me/+001-(XXX)XXXXXXX

The pre-filled message will automatically appear in the text field of a chat. Use https://wa.me/whatsappphonenumber?text=urlencodedtext where whatsappphonenumber is a full phone number in international format and urlencodedtext is the URL-encoded pre-filled message.

> Example: > https://wa.me/1XXXXXXXXXX?text=I'm%20interested%20in%20your%20car%20for%20sale

To create a link with just a pre-filled message, use https://wa.me/?text=urlencodedtext

> Example: > https://wa.me/?text=I'm%20inquiring%20about%20the%20apartment%20listing`

After clicking on the link, you’ll be shown a list of contacts you can send your message to.

Solution 16 - Android

This is correct if you want to open whatsapp in browser:

<a href=`https://web.whatsapp.com/send?text=${yout URL or TEXT}` ><Whatsapp</a>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionYochaiView Question on Stackoverflow
Solution 1 - AndroidManuelView Answer on Stackoverflow
Solution 2 - Androidad08View Answer on Stackoverflow
Solution 3 - AndroidjuangalfView Answer on Stackoverflow
Solution 4 - AndroidVincent DecauxView Answer on Stackoverflow
Solution 5 - AndroidHoldOffHungerView Answer on Stackoverflow
Solution 6 - AndroidAadil KeshwaniView Answer on Stackoverflow
Solution 7 - AndroidShriView Answer on Stackoverflow
Solution 8 - AndroidolifernaView Answer on Stackoverflow
Solution 9 - AndroidJonasBView Answer on Stackoverflow
Solution 10 - AndroidWeidenrindeView Answer on Stackoverflow
Solution 11 - AndroidRachit MangiView Answer on Stackoverflow
Solution 12 - AndroidSitaramView Answer on Stackoverflow
Solution 13 - AndroidJitendra Pal - JPView Answer on Stackoverflow
Solution 14 - AndroidGustavo CanteroView Answer on Stackoverflow
Solution 15 - AndroidWeDevelopView Answer on Stackoverflow
Solution 16 - AndroidOmid MoghadasView Answer on Stackoverflow