User Notifications

  • Local notifications now require user approval as well.
  • Apps must register notification settings (see UIUserNotificationSettings) by calling -[UIApplication registerUserNotificationSettings:].

Notification Actions

  • Two new actions when swiping to the left on the lock screen or notification center, or when swiping down on a notification banner.
  • Create actions using the UIMutableUserNotificationAction class.
  • Use UIMutableUserNotificationCategory to group actions for particular contexts (default and minimal).
    • Minimal is used in lock screen, notification center, and banners.
    • Default is used in notification alerts.

Remote Notifications

  • Need to include category identifier in push payload.
  • Previous size limit of 256 bytes for a payload has been increased to 2 KB.
  • Handle them using UIApplicationDelegate’s -application:handleActionWithIdentifier:forRemoteNotification:completionHandler:
  • Silent notifications require remote-notification in the UIBackgroundModes array in Info.plist.
  • Enabled by default, can be disabled in Settings, user is not prompted for approval until a notification is posted.
  • -[UIApplication registerForRemoteNotifications] is the new method for registering for remote notifications.

Local Notifications

  • Set category identifier using category property on UILocalNotification.
  • Handle them using UIApplicationDelegate’s -application:handleActionWithIdentifier:forLocalNotification:completionHandler:

Location Notifications

  • Need to register with Core Location using -[CLLocationManager requestWhenInUseAuthorization], which requests permission for tracking user location when the app is running in the foreground.
    • Define NSLocationWhenInUseUsageDescription key in Info.plist with a string value to set the usage text that appears in the authorization alert.
  • Handle CLLocationManagerDelegate’s -locationManager:didChangeAuthorizationStatus: callback to know when to schedule location based notifications.
  • UILocalNotification has new properties region and regionTriggersOnce for location based notifications, schedule them like any other local notification.