O'Reilly logo

Xcode 4 iOS Development by Steven F. Daniel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required