Push notifications worked now for month in my app without any problem. But having my app on an iOS 10 device causes problems. When the app is initially installed I can successfully enable push notifications with
UNUserNotificationCenter * center = [UNUserNotificationCenter currentNotificationCenter];
[center requestAuthorizationWithOptions:(UNAuthorizationOptionAlert + UNAuthorizationOptionSound + UNAuthorizationOptionBadge)
completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (granted) {
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
}];
and application:didRegisterForRemoteNotificationsWithDeviceToken: will be successfully called. Receiving push notifications works. But when I unregister from push notifications with
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
and try to re-register with the same code at the top again, neither application:didRegisterForRemoteNotificationsWithDeviceToken:, nor application:didFailToRegisterForRemoteNotificationsWithError: will get called. Closing the app and re-open doesn't help. Only uninstalling and reinstalling the app 'solves' the problem and my app is again correctly registering for push and receving the token.
I even checked to see if something is failing with the call to the apple servers when registering, but there isn't even any request after calling registerForRemoteNotifications for the second time.
What an I doind wrong? Is this an iOS 10 bug?