Vibration

As with audio sounds, vibration immediately grabs a user’s attention. What’s more, vibration works for nearly all users, including those who are hearing or visually impaired. Vibration is available, however, only on the iPhone platform at this time. Plus, it should be used sparingly. It puts a great drain on the device battery.

Using the same System Audio services, you can vibrate as well as play a sound. All you need is the following one-line call to accomplish it, as used in Recipe 3-7:

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

You cannot vary the vibration parameters. Each call produces a short 1- to 2-second buzz. On platforms without vibration support (such as the iPod touch and iPad), ...

Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.