Open Sergozh opened 4 years ago
I just played around with the haptics engine myself and thought it would be a great feature. @Zandor300 what do you think?
Just ran into the issue of not knowing whether a device has haptic feedback. I second the vote for hasHapticFeedback
. I'd really like to call that so I'd know whether this will work or not: UIImpactFeedbackGenerator(style: .medium).impactOccurred() // Does nothing on old devices
Many thanks
So this is the short snippet of how I want to check it:
/// All Taptic Engine Capable Devices
public static var allTapticEngineCapableDevices: [Device] {
return [.iPhone6s, .iPhone6sPlus, .iPhone7, .iPhone7Plus, .iPhone8, .iPhone8Plus, .iPhoneX, .iPhoneXR, .iPhoneXS, .iPhoneXSMax, .iPhone11, .iPhone11Pro, .iPhone11ProMax]
}
/// All Haptic Feedback Capable Devices
public static var allHapticFeedbackCapableDevices: [Device] {
return [.iPhone7, .iPhone7Plus, .iPhone8, .iPhone8Plus, .iPhoneX, .iPhoneXR, .iPhoneXS, .iPhoneXSMax, .iPhone11, .iPhone11Pro, .iPhone11ProMax]
}
public var hasTapticEngine: Bool {
return isOneOf(Device.allTapticEngineCapableDevices)
}
var hasHapticFeedback: Bool {
return isOneOf(Device.allHapticFeedbackCapableDevices)
}
Apparently there are also two versions of the Taptic Engine, where version two has additional capabilities. https://stackoverflow.com/a/42057620
Could you add bool vars such as
hasTapticEngine
andhasHapticFeedback
? Thank you.