I use this code inside my motionBegan function. And when i shake my device it vibrates. Is there a way to add a delay so vibration begins after 1 second later for example?
AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))
I use this code inside my motionBegan function. And when i shake my device it vibrates. Is there a way to add a delay so vibration begins after 1 second later for example?
AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))
Use GCD dispatch_after
. (The easiest way is with my delay
function, shown here: https://stackoverflow.com/a/24318861/341994.)
For Swift 3 and up, use a DispatchQueue
:
DispatchQueue.main.asyncAfter(.now() + 1.0) {
AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))
}