Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.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 如何重置目标c中的通知徽章编号?_Ios_Objective C_Iphone_Apple Push Notifications_Uilocalnotification - Fatal编程技术网

Ios 如何重置目标c中的通知徽章编号?

Ios 如何重置目标c中的通知徽章编号?,ios,objective-c,iphone,apple-push-notifications,uilocalnotification,Ios,Objective C,Iphone,Apple Push Notifications,Uilocalnotification,打开上一个通知后,我无法为下一个通知重置通知徽章号。您可以从应用程序本身设置徽章号,如下所示: [UIApplication sharedApplication].applicationIconBadgeNumber = 0; 通过将该值设置为0,可以重置徽章编号 要通过push更新徽章编号,您需要在有效负载中包括以下内容: "badge" : 0 在以下位置编写此代码: -(void)applicationWillEnterForeground:(UIApplication *)appli

打开上一个通知后,我无法为下一个通知重置通知徽章号。

您可以从应用程序本身设置徽章号,如下所示:

[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
通过将该值设置为0,可以重置徽章编号

要通过push更新徽章编号,您需要在有效负载中包括以下内容:

"badge" : 0
在以下位置编写此代码:

-(void)applicationWillEnterForeground:(UIApplication *)application {

    [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
 }

在调用之前注册通知

UIUserNotificationSettings * notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];

[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];

[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
可能重复的