Push not working on iPhone 6

I have used easyapns for push services in my application. Push works fine on iOS 8, but my client says push doesn't work on iPhone 6. I don't have an iPhone 6 to test. Anyone else will face the same problem. What could go wrong?

+3


source to share


1 answer


This is what I am working on for iOS 8 and iPHONE 6/6 +. iOS 8 has changed the way push notifications are registered. The following code will allow the device to register for push notifications on iOS 8 and pre iOS 8 devices.

put this code in your appDelegate.m in didFinishLaunchingWithOptions:

#ifdef __IPHONE_8_0
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) {
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert categories:nil];
    [[UIApplication sharedApplication] registerUserNotificationSettings:settings];
}  else {
    UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];
}
#else

UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];

#endif

      



Also, add this as a new method to appDelegate.m

#ifdef __IPHONE_8_0
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
    [application registerForRemoteNotifications];
}
#endif

      

let me know how it works.

+2


source







All Articles