Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/105.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 删除推送通知支持一段时间_Ios_Swift_Apple Push Notifications - Fatal编程技术网

Ios 删除推送通知支持一段时间

Ios 删除推送通知支持一段时间,ios,swift,apple-push-notifications,Ios,Swift,Apple Push Notifications,我正在使用聊天应用程序。该应用程序支持推送通知,但当应用程序从后台到前台时,我不想接收任何推送通知,因为这会导致一些问题。是否可以在一段时间内停止应用程序接收推送通知?请在此方法中添加以下行以删除远程通知 应用前景 应用程序背景 迅速地 在通知获取时间表的地方使用BOOL标志,在从后台到前台的过程中设置为true和false,这是一个简单的技巧。 - (void)applicationWillEnterForeground:(UIApplication *)application { NS

我正在使用聊天应用程序。该应用程序支持推送通知,但当应用程序从后台到前台时,我不想接收任何推送通知,因为这会导致一些问题。是否可以在一段时间内停止应用程序接收推送通知?

请在此方法中添加以下行以删除远程通知

应用前景

应用程序背景

迅速地


在通知获取时间表的地方使用BOOL标志,在从后台到前台的过程中设置为true和false,这是一个简单的技巧。
- (void)applicationWillEnterForeground:(UIApplication *)application
{
   NSLog(@"app will enter foreground");
   [[UIApplication sharedApplication] unregisterForRemoteNotifications];
}
- (void)applicationDidEnterBackground:(UIApplication *)application 
{
   NSLog(@"applicationDidEnterBackground");
   [application registerForRemoteNotifications];
}
func applicationDidEnterBackground(application: UIApplication)
{

     application.unregisterForRemoteNotifications()
}