Registration for local notification returns UIUserNotificationTypeNone after user selects "Allow" on iOS9

This worked in iOS 8 and earlier, so it could be a bug in the iOS 9 beta - or it might be a changed behavior.

After asking the user for permission to send local notifications -

        NSSet *categories = ...;
        UIUserNotificationType notificationTypes = UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert;
        UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:notificationTypes categories:categories];

        [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];

      

and the user selects "Allow" is application:didRegisterUserNotificationSettings:

called with [notificationSettings types] == UIUserNotificationTypeNone

.

However, the next time registerUserNotificationSettings

it starts it will be called with the correct permission types.

Apple's link does not say anything to indicate that this is intended, so this could be a bug.

Does anyone know what the problem is or how to get around it?

+3


source to share


2 answers


You can work around this behavior (which looks like a bug) by instead [application currentUserNotificationSettings]

inapplication:didRegisterUserNotificationSettings:



+1


source


Just discovered that Apple changed their method didRegisterUserNotificationSettings

Of

 - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings

      



To

- (void)application:(UIApplication * nonnull)application didRegisterUserNotificationSettings:(UIUserNotificationSettings * nonnull)notificationSettings

      

I don't know if this will solve the problem, but you can try.

-1


source







All Articles