1

Is there a way to detect if the model of an iPad supports Apple Pencil?

I can check for the [UIDeviceHardware platformString] which returns the model of iPad and I can get the Pro models, but I would like a definitive solution that works even for future iPad Pro models.

jscs
  • 63,694
  • 13
  • 151
  • 195
  • Maybe this helps: https://stackoverflow.com/questions/37133248/how-to-differentiate-whether-a-user-is-tapping-the-screen-with-his-finger-or-an or maybe https://stackoverflow.com/questions/32542250/detect-whether-apple-pencil-is-connected-to-an-ipad-pro?rq=1 – rmaddy Jun 15 '17 at 14:45
  • Both probably not exactly what you want, but you can either detect if there is an Apple Pencil connected using this: https://stackoverflow.com/a/41264961/1489885 or which device you’re running on using this: https://github.com/dennisweissmann/DeviceKit – HAS Jun 15 '17 at 14:47
  • The detection of a connected Apple Pencil doesn't work for me. Just need to know if the iPad has the capability. – Victor Alonso Barberan Jun 16 '17 at 08:56

1 Answers1

0

You can check if device supports 3D Touch with forceTouchCapability API, and additionally check if the device is an iPad with userInterfaceIdiom. For now there is no API to detect 3D Touch availability with fingers for iPad or Apple Pencil for iPhone.

if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad &&
    UIScreen.mainScreen.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)
{
    // this device in current state supports stylus
}
toma
  • 1,471
  • 12
  • 20