-3

Me and my team suffering from one month because of this issue, problem is apple push notifications are working for some time in all installed devices, but after that even one device also not getting any notifications, this is happening continuously please solve this problem. Where is that problem and how to resolve this issue, please help me. I've written the below code in didFinishLaunchingWithOptions method of AppDelegate

UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
Amit Singh
  • 2,648
  • 18
  • 48

1 Answers1

1

if you want to register for iOS 8 and iOS 7 need to do so in didFinishLaunchingWithOptions:

if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)])
{
    // iOS 8 Notifications
    // use registerUserNotificationSettings
    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
} else {
    // iOS < 8 Notifications
    // use registerForRemoteNotifications
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes: UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];
}
weso
  • 283
  • 3
  • 11