I am wondering how we could check if the new iOS 10 API UIFeebackGenerator
is available on the current device. There are some more things we would need to check
Based on Apple's UIFeedbackGenerator documentation, sounds like iOS does that for you.
Note that calling these methods does not play haptics directly. Instead, it informs the system of the event. The system then determines whether to play the haptics based on the device, the application’s state, the amount of battery power remaining, and other factors.
For example, haptic feedback is currently played only:
On a device with a supported Taptic Engine (iPhone 7 and iPhone 7 Plus).
When the app is running in the foreground.
When the System Haptics setting is enabled.
Even if you don't need to worry about check whether the device can do haptic feedback, you still need to ensure it's called only with iOS 10 or greater, so you could accomplish that with this:
if #available(iOS 10,*) {
// your haptic feedback method
}
Here's a quick summary of the various haptic feedback options available in iOS 10.