fb-share
Contact Us menu-bars menu-close

iOS 4.2 (Multitasking on iPad)

avatar

Ashish Jain

December 14, 2010

iOS 4.2 brings multitasking from iPhone and iPod touch to iPad. So what does it mean:

1. VOIP applications on iPad can now run in the background. User will now have the flexibility to use any other application (like surfing the web or check emails) while they are on VOIP call (calls over Wi-Fi connections). Prior to iOS 4.2, user has to actively use the application in order for it to be live.

So we will see more and more VOIP apps coming on Appstore.

What developer has to do:

Common steps for multitasking:

i. Determine whether multitasking is available:

Get the value of the multitaskingSupported property in the UIDevice class.

ii. Check for background support on earlier versions of iOS, if your app is supported on prior versions:

———–

UIDevice* device = [UIDevice currentDevice];

BOOL backgroundSupported = NO;

if ([device respondsToSelector:@selector(isMultitaskingSupported)])

backgroundSupported = device.multitaskingSupported;

————–

iii. Implement the App delegate methods and use it appropriately when the application is moved in background or foreground:

– Moving the app in background:

a. ApplicationWillResignActive

b. ApplicationDidEnterBackground

– Moving the app in foreground:

c. ApplicationWillEnterForeground

d. ApplicationDidBecomeActive

Steps for VOIP app to support multitasking:

i. Add the UIBackgroundModes key to your application’s Info.plist file. Set the value of this key to an array that includes the voip string.

ii. Configure socket for VoIP usage.

iii. Before moving to the background, call the setKeepAliveTimeout:handler: method to specify the frequency at which your application must be woken to maintain your service.

iv. Configure your audio session to handle transitions to and from active use.

2. Location based applications can now run in the background and keep informing the user of their location change.

i. Applications can register for significant location changes only. (Recommended)

You start this service by calling the startMonitoringSignificantLocationChanges method of CLLocationManager.

ii. Applications can continue to use the standard location services.

iii. An application can declare itself as a continuous background location application. For this, include the UIBackgroundModes key in its Info.plist file

3. The applications that plays audio content can now get benefit from iOS 4.2 on iPad such that they can now run in the background and continue playing audio.

To indicate that your application plays background audio, include the UIBackgroundModes key to its Info.plist file.

The value for this key is an array containing the audio string.

4. Completing a Long-Running Task in the Background.

For example, if your application uploads files on the server and while the operation is in progress, user presses the home button. What will happen? Prior to iOS 4.2, the operation is cancelled. Now you can make this operation run even while your application is in background.

i. Any time before app is suspended, an application can call the beginBackgroundTaskWithExpirationHandler: method to ask the system for extra time to complete some long-running task in the background. The system lets the application run for an additional amount of time instead of suspending it.

ii. The amount of time left for the application to run is available in the backgroundTimeRemaining property of the UIApplication object.

iii. Wrap any long-running critical tasks with beginBackgroundTaskWithExpirationHandler: and endBackgroundTask: calls. This protects those tasks in situations where your application is suddenly moved to the background.

iv. Wait for your application delegate’s applicationDidEnterBackground: method to be called and start one or more tasks then.

5. You can schedule the delivery of local notifications even when your application is in background.

i. The UILocalNotification class in UIKit provides a way to schedule the delivery of push notifications locally.

ii. A time-based application can ask the system to post an alert at a specific time in the future. For example, an alarm clock application would use this to implement alarms.

iii. An application running in the background can post a local notification to get the user’s attention.

iv. The local notification object contains information about the type of notification to deliver (sound, alert, or badge) and the time (when applicable) at which to deliver it.

Get updates. Sign up for our newsletter.

contact-bg

Let's explore how we can create WOW for you!