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

时间:2017-07-18 12:30:34

标签: ios objective-c iphone apple-push-notifications uilocalnotification

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

3 个答案:

答案 0 :(得分:2)

将此代码写在

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

    [UIApplication sharedApplication].applicationIconBadgeNumber = 0;
 }

答案 1 :(得分:0)

您可以按照以下方式从应用程序本身设置徽章编号:

[UIApplication sharedApplication].applicationIconBadgeNumber = 0;

通过将值设置为0,您将重置徽章编号

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

"badge" : 0

答案 2 :(得分:0)

在通话前注册通知

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

[[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];

[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
相关问题