if ([[[UIDevice currentDevice] systemVersion] floatValue] < 7.0) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(noApplePush) name:@"UIMoviePlayerControllerDidEnterFullscreenNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveApplePush) name:@"UIMoviePlayerControllerDidExitFullscreenNotification" object:nil];
}else if ([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0){
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(noApplePush) name:@"UIWindowDidBecomeHiddenNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveApplePush) name:@"UIWindowDidBecomeVisibleNotification" object:nil];
}else{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveApplePush) name:@"UIWindowDidBecomeHiddenNotification" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(noApplePush) name:@"UIWindowDidBecomeVisibleNotification" object:nil];
}
-(void)noApplePush{
NSLog(@"------进入--------");
// GNAppDelegate.shouldNotAlert = YES;
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"shouldNotAlert"];
}
-(void)receiveApplePush{
NSLog(@"------退出--------");
// GNAppDelegate.shouldNotAlert = NO;
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"shouldNotAlert"];
}
本文介绍了一种根据iOS系统版本不同而采用不同策略来控制应用是否接收苹果推送通知的方法。通过监听特定的通知来判断应用是否处于全屏播放状态,并据此决定是否阻止推送通知。
5631

被折叠的 条评论
为什么被折叠?



