Detecting iOS
I am not a fan of User Agent sniffing, but here is how you would do it:
var iOS = /iPad|iPhone|iPod/.test(navigator.platform);
Another way, relying on the userAgent
:
var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
iOS
will be either true
or false
Why not MSStream
Microsoft injected the word iPhone in IE11's userAgent
in order to try and fool Gmail somehow. Therefore we need to exclude it. More info about this and .
Below is IE11's updated userAgent
(Internet Explorer for Windows Phone 8.1 Update):
Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 930) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537