Time for action – handling alerts via sounds and vibrations

Before we can play any sound or perform vibrations on our iPhone, we must first import the AudioToolBox library so that we can make use of its properties and methods:

  1. Open the GetUsersAttentionViewController.m implementation file and add the following highlighted code as shown in the code snippet below:
    #import "GetUsersAttentionViewController.h"
    #import "AudioToolBox/AudioToolBox.h"
    @implementation GetUsersAttentionViewController
  2. Our next step is to implement our playAlertSound method. This method will be responsible for playing a short 30 second sound when the Play Alert Sound button is pressed. In the action event which you created for the Play Alert Sound button, add the following ...

Get Xcode 4 iOS Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.