Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL
Help

Building Universal Applications > Building Universal Applications - Pg. 21

Feedback: 0 Comments on this Section

need to import the header (put this in your declaration if you plan to implement the AVAudioSessionDelegate protocol discussed shortly): #import <AVFoundation/AVFoundation.h> You can also be notified of any changes in the availability of audio input, e.g. a second generation iPod touch user has plugged in headphones with microphone capabilities. First, nominate your class as a delegate: audioSession.delegate = self; And then declare it as implementing the AVAudioSessionDelegate protocol in the declaration: @interface YourAppDelegate : NSObject <UIApplicationDelegate, AVAudioSessionDelegate > Then implement the inputIsAvailableChanged: in the implementation: - (void)inputIsAvailableChanged:(BOOL)audioAvailable { NSLog(@"Audio availability has changed"); } GPS availability I'm going to cover the Core Location framework in detail in Chapter 3. However the short answer to a fairly commonly asked question is that, unfortunately, the Core Location framework does not provide any way to get direct information about the availability of specific hardware. However, while you cannot check for the availability of GPS using Core Location, you can require the presence of GPS hardware for your application to load (see "Setting Required Hardware Capabilities," later in this chapter). Magnetometer availability Fortunately Core Location does allow you to check for the presence of the magnetometer (digital compass) fairly simply: CLLocationManager *locationManager = [[CLLocationManager alloc] init]; BOOL magnetometerAvailable = locationManager.headingAvailable Setting Required Hardware Capabilities If your application requires specific hardware features in order to run you can add a list of required capabilities to your application's Info.plist file. Your application will not start unless those capabilities are present on the device. To do this, open you project and then click on your application's Info.plist file to open it in the Xcode editor. Click on the bottom most entry in the list. A plus button will appear to the right-hand side of the key-value pair table. Click on this button to add a new row to the table, and scroll down the list of possible options and select "Required device capabilities" (the UIRequiredDeviceCapabilities key). This will add an (empty) array to the plist file. The allowed values for the keys are: telephony, sms, still-camera, auto-focus-camera, video-camera, wifi, accelerometer, location-services, gps, magnetometer, microphone, opengles-1, opengles-2, armv6, armv7, peer-peer. A full description of the possible keys is given in the Device Support section of the iPhone Application Programming Guide available from the iPhone Development Center. Building Universal Applications The "iPhone Platform" now extends across three devices: the iPhone, the iPod touch and most recently the iPad. With the SDK 3.2 supports targeting three types of applications: iPhone applications, iPad applications and Universal applications.