- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidBecomeActiveBackground:) name:UIApplicationDidBecomeActiveNotification object:nil];
}
-(void)appDidEnterBackground:(NSNotification *)_notification
{
isAppInBackground = YES;
NSLog(@"App is in background");
}
-(void)appDidBecomeActiveBackground:(NSNotification *)_notification
{
isAppInBackground = NO;
NSLog(@"App is in foreground");
[[UIApplication sharedApplication] cancelAllLocalNotifications];
}
沒有留言:
張貼留言