title: Deep link/ One link for HTML emailer
body: <p>I am creating an HTML emailer for my client and they want one link for two buttons. when their users do not have their apps installed on their phones, they must be redirected to the default URL. I am not too bright in Javascript / jQuery because I am not able to find answers.
  If users have installed their applications on their mobile devices so in this scenario we need the HREF attribute to be changed as per the Android / iOS devices and the application installed on their device if the application is not installed the user will be sent to the default URL.</p>
  <p>I tried this method for the execution</p>
  <pre><code>&lt;script language=javascript&gt;
  &lt;!-- for button 1 --&gt;
      var windowsize = $(window).width();
      $(document).resize(function () {
  
          $(window).resize(function () {
              var windowsize = $(window).width();
          });
      })
      const getHref = () =&gt; {
          const element = document.getElementById(&quot;link-change&quot;);
          const IS_IPAD = navigator.userAgent.match(/iPad/i) != null;
          const IS_IPHONE = (navigator.userAgent.match(/iPhone/i) != null) || (navigator.userAgent.match(/iPod/i) != null);
  
          if (IS_IPAD || IS_IPHONE) {
              element.href = &quot;ios.com&quot;; // 
          }
          else {
              element.href = &quot;default.com&quot;; // default
  
              if (windowsize &lt; 768) {
                  element.href = &quot;android.com&quot;; // default
              }
              else {
                  element.href = &quot;default.com&quot;; // default
              }
          };
      };
  
      getHref();
  </code></pre>
  
  <pre><code>    const getHref2 = () =&gt; {
          const element = document.getElementById(&quot;link-change-first&quot;);
          const IS_IPAD = navigator.userAgent.match(/iPad/i) != null;
          const IS_IPHONE = (navigator.userAgent.match(/iPhone/i) != null) || (navigator.userAgent.match(/iPod/i) != null);
  
          if (IS_IPAD || IS_IPHONE) {
              element.href = &quot;ios.com&quot;; // 
          }
          else {
              element.href = &quot;default.com&quot;; // default
  
              if (windowsize &lt; 768) {
                  element.href = &quot;android.com&quot;; // default
              }
              else {
                  element.href = &quot;default.com&quot;; // default
              }
          };
      };
  
      getHref2();
  
  &lt;/script&gt;
  </code></pre>
  <p>this worked if the application was installed on the user's android device only and if the app is not installed on their devices it doesn't work at all.
  for iOS somehow this method is not working at all please let me know how I can achieve the desired outcome</p>