代码改变世界

How to correctly set application badge value in iOS 8?

2014-09-05 17:38  三戒1993  阅读(91)  评论(0编辑  收藏  举报

o modify the badge under ios8 you have to ask for permissions

    let settings = UIUserNotificationSettings(forTypes: UIUserNotificationType.Badge, categories: nil)
    UIApplication.sharedApplication().registerUserNotificationSettings(settings)

or in objC

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];