Push notification does not receive in iOS 10

My application is in the Appstore. Push notification works fine in iOS 9, but it doesn't work in iOS 10. I do not receive push notifications for iOS 10 devices. I checked the token and certificate on my server. All right. I also checked the notification properties in the application settings. Everything is good. But I did not receive any notifications. I just turn off and notify about my application. And I opened my application to check if the token is changing or not. It has been modified and updated on my server. Then I get the notification properly. Now it works great for my device.

I am worried if this will affect all users or just me. Anyone will find a suitable solution, please let me know.

Thanks in advance

+7
ios ios10 push-notification apple-push-notifications
source share
4 answers

Some changes are needed for iOS 10 with xCode 8 GM. You need to implement UserNotification.framework and their delegation methods to get push notifications working.

I solved the problem using the new UserNotification.framework. Please follow this link: Ask a question with a notification about a problem with iOS 10

+7
source share

" UserNotifications " is optional in iOS10. " UIUserNotificationSettings " still works in iOS10.

If you have the following code, it should work in iOS10.

[[UIApplication sharedApplication] registerUserNotificationSettings:settings]; 

But if you are building with Xcode8 and above, make sure that you have the following entry in rights . This entry will be added automatically after the inclusion of "Push Notifications" in the " Features ".

 <key>aps-environment</key> <string>development</string> 

In the release distribution assembly, this will automatically be changed to Next

 <key>aps-environment</key> <string>production</string> 
+6
source share

We need to change the code for iOS 10.

Appdelegate.h

 #import <UserNotifications/UserNotifications.h> @interface AppDelegate : UIResponder <UIApplicationDelegate,UNUserNotificationCenterDelegate> @end 

Check os version

 #define SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) 

Register Notification

 - (void)registerForRemoteNotifications { 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 { // Code for old versions } } 

Delegate method handel

 //foreground app. -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{ NSLog(@"User Info : %@",notification.request.content.userInfo); completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge); } -(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler{ NSLog(@"User Info : %@",response.notification.request.content.userInfo); completionHandler(); } 
+3
source share

On iOS 10, you must add the Push Push permission, so if you are β€œFix Issue” in Capabilities, the problem will be resolved automatically.

+1
source share

All Articles