Saw this same issue, Push Notifications stopped working on iOS10 using our own Parse Server, thus our Tokens seemed to expire after 2 to 3 days. We actually saw a development client not receiving any Push Notifications, and noted the token it sends up to Parse, and Parse would then use this very Token only to get a failed message from Apples APNS saying the Token wasn't valid. Thus Apple's APNS set us an expired Token. Once the tokens expire only thing the client can do to reactivate them was to delete the client and reinstall it, then they would work for another 2 to 3 days. Needless to say this really ****** off your users.
We then switched to this code (shown below) on the iOS client in the AppDelegate to register for Push Notifications and the problem seemed to mysteriously disappear thereafter, but we also made changes on our Parse Server to not send any more Push Notifications with expired Tokens and I think that actually fixed it. We also used the UNUserNotificationCenterDelegate in our AppDelegate along with its delegate methods. We also deleted all our expired Push Notification Certificates on our Portal, in addition we also updated our iOS Provisioning Profile and pointed Xcode's Main Target to this Certificate in the Provisioning Profile (Deprecated) key . My guess is Apple's APNS when it gets a bunch of expired Tokens to send Push Notifications out on decides for whatever reason to expire the current active Token which it should never do. We called Apple on this, and generated a formal TSI event, but their help was minimal at best, but they did confirm that you should not generate Push Notifications with expired Tokens, and if you do APNS might retire a Token. Once Apple hears your using Parse, they don't want to help, at all, and I imagine half the world is using the open source version of Parse to generate their push notifications. We also stopped supporting iOS8, and only support iOS9 and iOS10 now.
#define SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
- (void)registerForRemoteNotification
{
if(SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(@"10.0"))
{
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){
if( !error ){
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
}];
}
else
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
}
#pragma mark - UNUserNotificationCenter Delegate
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{
[self application:[UIApplication sharedApplication] processRemoteNotification:notification.request.content.userInfo];
//We set this for UNNotificationPresentationOptionNone since we have our own internal notification banner
completionHandler(UNNotificationPresentationOptionNone);
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler{
/
[self application:[UIApplication sharedApplication] processRemoteNotification:response.notification.request.content.userInfo];
completionHandler();
}
- (void)application:(UIApplication *)application processRemoteNotification:(NSDictionary *)userInfo
{
//Process your Push Notification here
}