我正在开发聊天app.App支持推送通知但是当应用程序从后台到前台我不想接收任何推送通知,因为它导致了一些问题。是否有可能阻止应用程序接收某些推送通知时间?
答案 0 :(得分:0)
请在此方法中添加以下行以删除远程通知
applicationWillEnterForeground
- (void)applicationWillEnterForeground:(UIApplication *)application
{
NSLog(@"app will enter foreground");
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
}
applicationWillEnterBackground
- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSLog(@"applicationDidEnterBackground");
[application registerForRemoteNotifications];
}
在Swift中
func applicationDidEnterBackground(application: UIApplication)
{
application.unregisterForRemoteNotifications()
}