4
votes

Note that this question applies to iOS 6, which was the highest production version of iOS at the time I asked the question. I have done no subsequent testing on later versions of iOS, and things may well have changed. If you observe the same behaviour on later versions of the OS, please comment!

My app registers for push notifications. The permissions dialog ("MyApp Would Like to Send You Push Notifications") appears. There are two possible flows:

a) User selects OK. Settings->Notifications->MyApp then shows full permissions for alerts, as I'd expect.

or

b) THIS IS THE BUG User selects Cancel. I'd expect Settings->Notifications->MyApp to show the app as not in Notification Centre, with all permissions off. However, the opposite is true - no difference to the case where they OK the dialog!

Apart from my application, I have found that BBC News and Ap Mobile exhibit the same bug, while Viber does not (works exactly as I would expect). Ap Mobile has a variant of this bug - if I decline Push Notifications, only Badges are on, not Sounds and Alerts.

I am resetting the state of push settings by restoring to a backup made before running the app, as per TN2265.

1

1 Answers

2
votes

Following an infinity of restores and testing, I found the following.

If the user selects Cancel in the "xxx would like to send you push notifications" then alerts will be off in Settings->Notifications->App Name, unless

a) A call to cancelAllLocalNotifications was made before registerForRemoteNotificationTypes:, in which case all alerts will be on. This feels like a Apple bug.

or b) A call to setApplicationIconBadgeNumber:0 (didn't try other numbers) was made before registerForRemoteNotificationTypes: was made, in which case only badges will be on. Arguably, it's reasonable to enable badges if we actually set the badge number, so it's not totally obvious that this is a bug rather than an (undocumented) feature.

A workaround for this bug/feature is to check that push is enabled before touching it.

    // If remote notifications are already enabled, then clear any existing.
    if([[UIApplication sharedApplication] enabledRemoteNotificationTypes] != UIRemoteNotificationTypeNone)
    {
        [[UIApplication sharedApplication] cancelAllLocalNotifications];
        [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
    }