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

Get Beginning iOS 5 Application Development 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.