Skip to content

iPad not correctly detected on iOS 13 and 14 #5389

@SBCGames

Description

@SBCGames

Version

  • Phaser Version: all versions including latest 3.50 - beta X
  • Operating system: iOS
  • Browser: Safari on iPad

Description

Since iOS 13 Apple changed user agent string on iPad devices to something like this:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.2 Safari/605.1.15

So, device is recognized as macOS in https://github.com/photonstorm/phaser/blob/master/src/device/OS.js#L70 It means that app behaves like desktop (=true) app on iPad.

Workaround I found on internet is to check support for maxTouchPoints to make decision between macOS and iPad. Adjusting code like this worked for me:

    else if ((/Mac OS/).test(ua) && !((/like Mac OS/).test(ua)))
    {
        if (navigator.maxTouchPoints && navigator.maxTouchPoints > 2) {
            OS.iOS = true;
            OS.iPad = true;

            (navigator.appVersion).match(/Version\/(\d+)/);
            OS.iOSVersion = parseInt(RegExp.$1, 10);
            
        } else {
            OS.macOS = true;
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions