Search code examples
iospush-notificationios9

Push notification does not appear if app is in background on iOS 9


I'm having an issue with push notifications and it affects only my devices running iOS 9:

  1. I have my app installed in a set of devices. I run it and register for push notifications with the following code:
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
    UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound);
    UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes categories:nil];
    [application registerUserNotificationSettings:settings];
    [application registerForRemoteNotifications];
}
  1. The app is put on background on all devices.
  2. I send push notifications to all devices - and get the response that it succeeded.
  3. All iOS 8 devices display the push notification in the notification center.
  4. NO iOS 9 device display the push notification in the notification center.
  5. Open the app in any of the iOS 9 devices in some random moment. The notification is displayed (triggered by application:didReceiveRemoteNotification:).

Has anything changed on iOS 9? How can I make the push notifications display also on iOS 9, even if the app is not active? I don't want to use notifications to fetch any content in background, I just need to display a message.


Solution

  • In the end, I had to do two things that made it work for me:

    • Enable "Remote Notifications" for Background Modes under the Application capabilities (in the target settings)
    • Send the notifications with high priority (when they were sent with low priority, they were not being handled with the application on background)