What’s New in User Notifications

UserNotifications framework in iOS 12

What’s New in User Notifications

UserNotifications framework in iOS 12

Now, with their new iOS 12 update announced on Jun 4., Apple has a solution for uncontrollable notifications: Grouped Notifications , But it has lot more new things in UserNotifications framework to checkout.

  • Grouped notifications
  • Notification content extensions
  • Notification management
  • Provisional authorization
  • Critical alerts

Grouped notifications

It has two types -
1. Automatic grouping
2. Thread identifier (add in your APNS payload or define in local notification)

Grouped Notifications

This feature does exactly what it sounds like: it groups together similar notifications into one. For example, if you get multiple messages from one person or one group text message thread, you’ll get one notification for all of them instead of one notification for each single message — and if you want to look at every notification, you can simply just click “See More” to scroll through them all. This will work for any of the apps on the iPhone with iOS 12, not just Messages.

Notification Content Extensions

The notification content app extension manages a view controller that displays your custom notification interface. This view controller can supplement or replace the default system interface for your notifications. You can use your view controller to:

  • Customize the placement of items, including the alert’s title, subtitle, and body text.
  • Substitute different fonts or styling for interface elements.
  • Display app-specific data — for example, data stored in app-specific keys of the notification’s payload.
  • Include custom images or branding.

Support Interactive Controls

In iOS 12 and later you can enable user interactions in your custom notifications. This lets you add interactive controls, such as buttons and switches to your custom interface.

To enable user interactions:

  1. Open your Notification Content Extension’s info.plist file.
  2. Add the UNNotificationExtensionUserInteractionEnabled key to your extension attributes. Give it a Boolean value, set to YES.

Notification management

To help reduce interruptions, iOS 12 gives customers more options for controlling how notifications are delivered. Instantly manage notifications to be turned off completely or delivered directly to Notification Center. Siri can also intelligently make suggestions for notifications settings, such as to quietly deliver or turn alerts off, based on which alerts are acted upon. iOS 12 also introduces Grouped Notifications, making it easier to view and manage multiple notifications at once.

Manage notifications

Provisional authorization

UNAuthorizationOptions Constants for requesting authorization to interact with the user, The ability to post noninterrupting notifications provisionally to the Notification Center.

static var provisional: UNAuthorizationOptions

Critical Alerts

Critical alerts ignore the mute switch and Do Not Disturb; the system plays a critical alert’s sound regardless of the device’s mute or Do Not Disturb settings. You can specify a custom sound and volume.

Critical alerts require a special entitlement issued by Apple.

Critical alert with custom sound and custom audio volume

let content = UNMutableNotificationContent() 
content.title = “WARNING: LOW BLOOD SUGAR”
content.body = “Glucose level at 57.”
content.categoryIdentifier = “low-glucose — alert”
content.sound = UNNotificationSound.criticalSoundNamed(@”warning-sound” withAudioVolume: 1.00)

Critical alert push payload

{ “aps” : { “sound” : { “critical”: 1, “name”: “warning-sound.aiff”, “volume”: 1.0 } } }

Hope you like this article & is useful for people looking to find out the new things in UserNotifications framework, Please ❤️ to recommend this post to others 😊. Let me know your feedback. :)