How to increment application badge number for recu

2019-02-05 03:26发布

I've setup a local notification that repeats every minute, however I need the application badge number to increment each time. When I run it at the moment it doesn't seem to increase, it just stays a 1. Please can someone help me out?

Here is how I create the notifications:

// Create the UILocalNotification
UILocalNotification *myNotification = [[UILocalNotification alloc] init];
myNotification.alertBody = @"Blah blah blah...";
myNotification.alertAction = @"Blah";
myNotification.soundName = UILocalNotificationDefaultSoundName;
myNotification.applicationIconBadgeNumber++;
myNotification.timeZone = [NSTimeZone defaultTimeZone];
myNotification.repeatInterval = NSMinuteCalendarUnit;
myNotification.fireDate = [[NSDate date] dateByAddingTimeInterval:30];
[[UIApplication sharedApplication] scheduleLocalNotification:myNotification];

7条回答
对你真心纯属浪费
2楼-- · 2019-02-05 04:32

This should work.

myNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;
查看更多
登录 后发表回答