How to check the availability of Haptic Touch

We check [UIApplication sharedApplication].keyWindow.traitCollection.forceTouchCapability = UIForceTouchCapabilityAvailable to find the 3D touch support. If supported we added shortcut items to the application.


But in iPhone XR above check always return false.
How to validate whether the device has supported Haptic Touch or not ?

Answered by Claude31 in 416406022

Several solutions described here:

https://stackoverflow.com/questions/41444274/how-to-check-if-haptic-engine-uifeedbackgenerator-is-supported



import CoreHaptics
var supportsHaptics: Bool = false
// Check if the device supports haptics.
let hapticCapability = CHHapticEngine.capabilitiesForHardware()
supportsHaptics = hapticCapability.supportsHaptics



Tested on iPhone Xs. returns true, as expected


Note it does not work on simulator (tested with XCode 11.3 on iPhone 11Pro 13.3): returns false

Accepted Answer

Several solutions described here:

https://stackoverflow.com/questions/41444274/how-to-check-if-haptic-engine-uifeedbackgenerator-is-supported



import CoreHaptics
var supportsHaptics: Bool = false
// Check if the device supports haptics.
let hapticCapability = CHHapticEngine.capabilitiesForHardware()
supportsHaptics = hapticCapability.supportsHaptics



Tested on iPhone Xs. returns true, as expected


Note it does not work on simulator (tested with XCode 11.3 on iPhone 11Pro 13.3): returns false

How to check the availability of Haptic Touch
 
 
Q