How can the iPhone be set to vibrate once?
For example, when a player loses a life or the game is over, the iPhone should vibrate.
There are two seemingly similar functions that take a parameter
1) AudioServicesPlayAlertSound(kSystemSoundID_Vibrate); 2) AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
Both of the functions vibrate the iPhone. But, when you use the first function on devices that don’t support vibration, it plays a beep sound. The second function, on the other hand, does nothing on unsupported devices. So if you are going to vibrate the device continuously, as an alert, common sense says, use function 2.
First, add the AudioToolbox framework
AudioToolbox.framework to your target in Build Phases.
Then, import this header file: