title: How to detect device name in Safari on iOS 13 while it doesn't show the correct user agent?
body: <p>After Apple's iOS 13 release, I realized <strong><code>window.navigator.userAgent</code></strong> in Safari on iPad iOS 13 is same as on MacOS. Something like this:</p>
  <p><code>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Safari/605.1.15</code></p>
  <p>As you see, it's a wrong user-agent for iPad and there is no way to detect if the current device is an iDevice.</p>
  <hr />
  <p>After an initial research, I found a workaround for it:</p>
  <blockquote>
  <p>Go to Settings -&gt; Safari -&gt; Request Desktop Website -&gt; All websites. You notice &quot;All websites&quot; is <strong>enabled by default</strong>. If you <strong>disable</strong> it and get window.navigator.userAgent the correct user agent is now displayed.</p>
  </blockquote>
  <p>But I cannot ask each user to do this setting change for each device. So I tried to find another way and ended up by writing <strong>the following code which checks if it's Safari, macOS, and touch-screen then the device should be an apple mobile device</strong>, but I'm wondering is there any better suggestion/way to detect the correct device name in Safari iOS 13?</p>
  <pre class="lang-js prettyprint-override"><code>detectOs = function(){
     //returns OS name, like &quot;mac&quot;
  };
  
  //is Safari on an apple touch-screen device
  isSafariInIdevice = function(){
     if (/Safari[\/\s](\d+\.\d+)/.test(windows.navigator.userAgent)) {
        return 'ontouchstart' in window &amp;&amp; detectOs() === &quot;mac&quot;;      
     }
     return false;
  };
  </code></pre>