Start WhatsApp from URL HREF with custom text/content

前端 未结 7 1761
醉酒成梦
醉酒成梦 2020-12-24 13:47

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

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

this is possibl

相关标签:
7条回答
  • 2020-12-24 14:18

    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

    0 讨论(0)
  • 2020-12-24 14:22

    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

    0 讨论(0)
  • 2020-12-24 14:22

    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");
    
                          }
                      };
    
                  }
              });
    
    0 讨论(0)
  • 2020-12-24 14:33

    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.

    Update: If the user uses the web app, that link will do nothing. What I do is to provide that link for mobile and this other one for desktop users:

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

    You can do it through a CSS @mediaquery or just making the domain dynamic.

    The reason why I use two different methods instead of the API "wa.me/?text=menssage", is to avoid the user a hard time trying to open whatsapp aswering questions he probably don't cares about.

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

    0 讨论(0)
  • href="intent://send/4912345678#Intent;
    scheme=smsto;
    package=com.whatsapp;
    action=android.intent.action.SENDTO;end
    

    This will not work with iPhones.

    0 讨论(0)
  • 2020-12-24 14:35

    You can actually just easily create your own link and it will automatically handle it.

    Immediately, you can create a chat with the number without adding them in your contact book.

    Here is if you just want to create a chat. 15551234567 is your phone number with your country code as prefix, don't include the + sign.

    https://wa.me/15551234567

    Here is if you want to include a pre-filled text message.

    https://wa.me/15551234567?text=Hello There. General Kenobi!

    For more information, check out WhatsApp own documentation.

    https://faq.whatsapp.com/en/26000030/

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题