Start WhatsApp from URL HREF with custom text/cont

2020-02-19 06:15发布

As you know using the whatsapp url scheme on iphone i can create the following link:

href="whatsapp://send?text=blahblah"

this is possible due to the url scheme support on ios.

im try to create the similar effect for android devices. (but no threw android app, just a normal html page).

to my understanding it should be something like:

href="intent://send/#Intent;scheme=whatsapp;package=com.whatsapp;s.text=test;end;"

or:

href="intent://send/#Intent;scheme=whatsapp;package=com.whatsapp;text=test;
     action=android.content.Intent.ACTION_SEND; end"

or:

href="intent://send/#Intent;scheme=whatsapp;package=com.whatsapp;text=test;
      category=android.intent.category.BROWSABLE;end"

as you can see im really groping in the dark. all the answers i've found on stackoverflow are talking about how to generate the intent threw the android app.

BUT thats not my case, i want to generate an href on a PHP/ASP server for an html page.

someone? thanks!

6条回答
贪生不怕死
2楼-- · 2020-02-19 06:34

Whatsapp url scheme working only saved ids or numbers for jump message send screen. Android working with message activity for new phone numbers.

This script Looking phone os and create link for phone os.

        $(document).ready(function () {

              if (matchMedia) {
                  var mq = window.matchMedia("(max-width: 991px)");
                  mq.addListener(WidthChange);
                  WidthChange(mq);
              }

              function WidthChange(mq) {
                  var isMobile = {
                      Android: function () {
                          return navigator.userAgent.match(/Android/i);
                      },
                      BlackBerry: function () {
                          return navigator.userAgent.match(/BlackBerry/i);
                      },
                      iOS: function () {
                          return navigator.userAgent.match(/iPhone|iPad|iPod/i);
                      },
                      Opera: function () {
                          return navigator.userAgent.match(/Opera Mini/i);
                      },
                      Windows: function () {
                          return navigator.userAgent.match(/IEMobile/i);
                      },
                      any: function () {
                          return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
                      }
                  };




                  if (mq.matches) {
                      if (isMobile.Android()) {
                          $("a").attr("href", "intent://send/+905055555#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end");
                      } else {
                          $("a").attr("href", "tel:+905555555555");

                      }
                  };

              }
          });
查看更多
smile是对你的礼貌
3楼-- · 2020-02-19 06:41

I think the answer you where looking for is this:

<a href="whatsapp://send?text=my message&phone=+XXXXXXXXXXX&abid=+XXXXXXXXXXX">Whatsapp me please</a>

This code works both in Android and iOS thanks to the parameters "phone" and "abid" respectively.

Sorry for the late response, hope it helps somebody anyway.

查看更多
爷的心禁止访问
4楼-- · 2020-02-19 06:42

I used this href="intent://send/4912345678#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end

but in this code cant include the text

查看更多
放我归山
5楼-- · 2020-02-19 06:50
href="intent://send/4912345678#Intent;
scheme=smsto;
package=com.whatsapp;
action=android.intent.action.SENDTO;end

This will not work with iPhones.

查看更多
smile是对你的礼貌
6楼-- · 2020-02-19 06:57

whatsapp now officially support url scheme over Android(Yey)!

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

for more details visit http://www.whatsapp.com/faq/en/android/28000012

查看更多
家丑人穷心不美
7楼-- · 2020-02-19 06:57

Was working on the same Problem and found the solution:

href="intent://send/[countrycode_without_plus][number]#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end

With a telephonenumber(+49 123 456 78)

href="intent://send/4912345678#Intent;scheme=smsto;package=com.whatsapp;action=android.intent.action.SENDTO;end
查看更多
登录 后发表回答