How to correctly set application badge value in iOS 8?

前端 未结 5 1749
故里飘歌
故里飘歌 2020-12-24 06:38

Old method

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:count];

is now gives error Attempting to badge the applic

5条回答
  •  臣服心动
    2020-12-24 07:32

    In addition to Daij-Djan's answer: it's possible to stack the enums so you can request them all at once. Like follows:

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

    Debug output mentions I should ask for Application Badge permission

提交回复
热议问题