Search code examples
iosswiftobjective-cipad

UIDevice.current.userInterfaceIdiom is phone even while running the app on an iPad


Problem:

If I deselect iPad as a device that I want to deploy to, as shown below: enter image description here

and then run my app using debug/TestFlight on my iPad, UIDevice.current.userInterfaceIdiom (from here) returns phone instead of pad.

Question:

How can I detect that the app is running on an iPad in this state?

Context

The problem is that this Stair Climber app, that you can test here requires HealthKit to work, and iPads don't have the Health app, so I can't pull in Flights Climbed data into the app, so the app is basically useless. And even though I deselect iPad and don't add iPad pictures to the listing, the App Store review team rejected me for the UX on iPads -,-. That is why I want the user to have a different experience if they are not using iPhones.


Solution

  • UIDevice.current.userInterfaceIdiom is not about device but about currently active interface idiom of the supported, but which you actually turned off.

    You can use UIDevice.current.model property to detect if real device is iPad.