- (void)applicationDidEnterBackground:(UIApplication *)application
{
UIBackgroundTaskIdentifier identifier = UIBackgroundTaskInvalid;
identifier = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
[[UIApplication sharedApplication] endBackgroundTask:identifier];
}];
}
Update: After some searching and trying, I found that a better way is to listen to UIApplicationDidEnterBackgroundNotification event in my class, and I do not need to use the background task hack anymore then.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
No comments:
Post a Comment