How to correctly set application badge value in iOS 8?

前端 未结 5 1756
故里飘歌
故里飘歌 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:36

    to 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];
    

提交回复
热议问题