註冊 iPhone 多工背景播放音樂

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
 
    // Override point for customization after application launch.
    [self.window addSubview:tabBarController.view];
    [self.window makeKeyAndVisible];
 
	UIDevice *thisDevice = [UIDevice currentDevice];
 
	if([thisDevice respondsToSelector:@selector(isMultitaskingSupported)]
	   && thisDevice.multitaskingSupported) {
		UIBackgroundTaskIdentifier backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{
			/* just fail if this happens. */
			NSLog(@"BackgroundTask Expiration Handler is called");
			[application endBackgroundTask:backgroundTask];
		}];
	}
 
    return YES;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.