[BUG] Ipad platform detection issue

Hello,

There’s an issue on Ipad. Both pc.platform.ios and pc.platform.mobile return false so there’s no way to know you’re on an iPad. I haven’t looked at the code but my guess is that PC thinks it’s on a Mac since Safari on iPad now uses the desktop version.

Here’s a quick fix it for it:

var userAgent = window.navigator.userAgent,
    platform = window.navigator.platform,
    macosPlatforms = ['Darwin','Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'],
    windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'],
    iosPlatforms = ['iPhone', 'iPad', 'iPod'],
    os = null;

if (macosPlatforms.indexOf(platform) !== -1) {
    if (window.devicePixelRatio == 2 && navigator.maxTouchPoints > 0) {
        os = 'ipad';
    }
    else {
        os = 'Mac';
    }
}

iPad OS Safari has now changed that it requests the desktop version of the site instead. To detect an iPad now is pretty hacky :frowning:

See more here: https://developer.apple.com/forums/thread/119186

1 Like

Added bug here: https://github.com/playcanvas/engine/issues/2383

1 Like