Last edit
Changed:
< if(settings.types & (UIUserNotificationTypeSound | UIUserNotificationTypeAlert)) {
to
> if(settings.types & (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)) {
Changed:
< [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil]];
to
> [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
On iOS 8, user permission is required for scheduling local notifications (of class UILocalNotification). Here's an Objective-C example.
To check whether you have permission:
- (BOOL)appHasPermissionForLocalNotifications { UIUserNotificationSettings *settings = [[UIApplication sharedApplication] currentUserNotificationSettings]; if(settings.types & (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)) { NSLog(@"Permission present: 0x%ulX", settings.types); return YES; } else { NSLog(@"Permission not present: 0x%ulX", settings.types); return NO; } }
To request permission:
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];