`UIApplication.unregisterForRemoteNotifications` is no longer safe to use, does not allow re-registration

Originator:bryan
Number:rdar://28875922 Date Originated:20-Oct-2016 04:13 PM
Status:Open Resolved:
Product:iOS SDK Product Version:10
Classification:Serious Issue Reproducible:Yes
 
Summary:

As of iOS 10, after calling `UIApplication.unregisterForRemoteNotifications()`, you are unable to re-register (at least for some period of time). This contradicts the documentation, which states that “apps unregistered through this method can always re-register.”

This is important because there’s no other good way to prevent a user from getting push notifications, if they’ve logged out. You could make an HTTP request to your own server to tell it to stop sending them to this device, but this requires the user to be online at the time when they log out (or for the HTTP request to be queued up and executed later, which would mean keeping the logged out user’s tokens around longer than necessary). Alternatively, you could introspect push notification payloads and compare them against the currently authenticated user before allowing the notification to be shown, but this is unnecessary engineering effort.

Steps to Reproduce:
- Call `UIApplication.unregisterForRemoteNotifications()` on iOS 10
- Call `UIApplication.registerForRemoteNotifications()`

Expected Results:

One of the following `UIApplicationDelegate` methods would be called:

`application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData)`
`application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError)`

Actual Results:

Neither of those `UIApplicationDelegate` methods are called.

Regression:

Prior to iOS 10, you could re-register after unregistering.

Comments

This issue has been fixed in iOS10.2

By sangeethab24 at Dec. 27, 2016, 7:22 a.m. (reply...)

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!