Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to correctly set application badge value in iOS 8?

Tags:

ios8

Old method

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:count]; 

is now gives error Attempting to badge the application icon but haven't received permission from the user to badge the application.

Then I tried to use new API (that I'm think is related to badge value)

CKModifyBadgeOperation * operation = [[CKModifyBadgeOperation alloc] initWithBadgeValue:50]; [operation setModifyBadgeCompletionBlock:^(NSError *error) {       NSLog(@"%@", error); }]; [operation start]; 

But I'm receiving error <CKError 0x165048a0: "Not Authenticated" (9/1002); "This request requires an authenticated account">

How to set badge or receive some new permissions?

like image 370
Roman Truba Avatar asked Jun 03 '14 17:06

Roman Truba


1 Answers

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

like image 193
Lucas van Dongen Avatar answered Sep 21 '22 05:09

Lucas van Dongen