Reputation: 287
How can I invoke vibration using Swift and control its duration? Also what other parameters can be defined? I would like to invoke a very short vibration using Swift.
I tried the following function:
func () {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
}
but I get this error:
'Int' is not convertible to 'SystemSoundID'
Upvotes: 5
Views: 3757
Reputation: 238
I have the same issue but using 1352
instead of kSystemSoundID_Vibrate
works for me.
AudioServicesPlaySystemSound(1352)
The above solution was used as a temporary workaround. As pointed out by many others, it is better to use AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))
as the above solution is not fail proof.
Upvotes: -4
Reputation: 6081
This would be a better solution:
AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))
Upvotes: 26