I've already test how to make a vibration like this: How to make iPhone vibrate using Swift?
But I search how to make a very short vibration (0,5 seconds for example) in one time.
Can anyone help me? Thank you :)
I've already test how to make a vibration like this: How to make iPhone vibrate using Swift?
But I search how to make a very short vibration (0,5 seconds for example) in one time.
Can anyone help me? Thank you :)
AFAIK you can't change the vibration duration of the "vibrate" system sound.
For shorter vibrations you could try to use taptic feedback, e.g.
let tapticFeedback = UINotificationFeedbackGenerator()
tapticFeedback.notificationOccurred(.success)
If you have the right kind of iPhone and you're willing to confine yourself to iOS 13 and later, you can use Core Haptics to create any kind of vibration you like.
Pretty easy actually. First you import AVfoundation
import AVFoundation
Then create a UIDevice extension with a static function inside and call AudioServicesPlaySystemSound
extension UIDevice {
static func vibrate() {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
}
}
Then use anywhere in your app like so
UIDevice.vibrate()