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:
- Open the
GetUsersAttentionViewController.mimplementation file and add the following highlighted code as shown in the code snippet below:
#import "GetUsersAttentionViewController.h" #import "AudioToolBox/AudioToolBox.h" @implementation GetUsersAttentionViewController
- Our next step is to implement our
playAlertSoundmethod. 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 ...