O'Reilly logo

Beginning iOS 5 Application Development by Wei-Meng Lee

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

IMPLEMENTING VOICE CHATTING

Another cool feature of the Game Kit framework is its support for voice chat.

The Voice Chat service in the Game Kit enables two devices to establish a voice chat. The voice chat takes place over either an Internet connection or a Bluetooth connection. This section shows you how to implement voice chatting over a Bluetooth communication channel.

TRY IT OUT: Enabling Bluetooth Voice Chatting

image

  1. Using Xcode, create a new Single View Application (iPhone) project and name it BluetoothChat. You need to use the project name as the Class Prefix and ensure that you have the Use Automatic Reference Counting option unchecked.
  2. Add the GameKit and AVFoundation frameworks to the Frameworks folder of the project (see Figure 17-8).
  3. Drag and drop a WAV file (see Figure 17-9) onto the Resources folder in Xcode.

    image

    FIGURE 17-8

    image

    FIGURE 17-9

  4. Select the BluetoothViewController.xib file to edit it in Interface Builder.
  5. Populate the View window with three Round Rect Button views (see Figure 17-10). Label them MUTE, Disconnect, and Connect.
  6. Add the following bold statements to the BluetoothChatViewController.h file:
    #import <UIKit/UIKit.h>
    #import <GameKit/GameKit.h>
    #import <AVFoundation/AVFoundation.h> ...

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