Start WhatsApp from URL HREF with custom text/content

前端 未结 7 1800
醉酒成梦
醉酒成梦 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: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");
    
                          }
                      };
    
                  }
              });
    

提交回复
热议问题