Should be notified when user changes notification settings for an app, particularly "Badge App Icon"

Originator:mbabin
Number:rdar://18341265 Date Originated:15-Sep-2014 03:24 PM
Status:Open Resolved:
Product:iOS SDK Product Version:8.0
Classification:Enhancement Reproducible:N/A
 
Summary:
An app should be able to register for a notification or implement a delegate callback (UIApplicationDelegate?) to be notified when the user has changed the notifications settings for the app (Settings > App > Notifications > ), particularly the "Badge App Icon" setting.

Currently, if an app registers user notification settings to change the app icon's badge number and the user denies permission, then setting the icon badge number results in a console message, indicating that the app should not do so. If the user subsequently enables the "Badge App Icon" setting, the badge number is displayed with the last value, if any, set by the app. There is no opportunity for the app to be notified that the setting has been enabled and to update the badge number appropriately. This causes the app to continue to update the badge number even when permission is denied, since a console warning is preferable to displaying incorrect data to the user.

Steps to Reproduce:
I'm working on an app that, as part of its functionality, updates the app's icon badge number to reflect the number of "pending items":

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:updatedCount];
 
When running on iOS 8 (GM), this triggers the following message to the console:
     "Attempting to badge the application icon but haven't received permission from the user to badge the application"
 
Reviewing the documentation and WWDC 2014 Session 713 (What's New in iOS Notifications), leads to registering user notification settings for badging the app's icon:
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];

Which presents an alert to the user (once), asking for permission with the title:
     "<App Name>" Would Like to Send You Notifications
and message:
     Notifications may include alerts, sounds, and icon badges. These can be configured in Settings.
 
When I update the icon badge, I check the notification settings and only update if allowed:
UIUserNotificationSettings *settings = [[UIApplication sharedApplication] currentUserNotificationSettings];
if (settings.types & UIUserNotificationTypeBadge) {
     [[UIApplication sharedApplication] setApplicationIconBadgeNumber:updatedCount];
}

This eliminates the console message and updates the icon badge only when the user allows the app to "Badge App Icon" (in Settings).
 
When the user enables the "Badge App Icon" option in Settings, the icon badge displays the last value of applicationIconBadgeNumber which was set (if any), but it hasn't been updated while the "Badge App Icon" setting was disabled. I looked for a delegate method or notification, but the only one I found was the delegate method -[UIApplicationDelegate application:didRegisterUserNotificationSettings:], which is not called when the Settings value changes (only when the settings are first registered).

Expected Results:
A notification or delegate callback that the app could receive when the user changes the user notification settings in the Settings app, particularly the "Badge App Icon" setting.

Actual Results:
No such notification or delegate callback is currently available.

Version:
iOS 8.0 (12A365)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!