Advanced Notification Options

In this topic:

Focus Modes and Notification Summary:

From iOS 15, Apple has introduced two important system control features: Focus modes and Notification Summary. These features provide more user control over how and when they want to receive and interact with push notifications.

Note: These features are not enabled by default and need to be set manually by the user.

  • Focus Modes is an enhanced or improvised version of the previously available "Do not Disturb" mode. It lets you add different "focus modes" to filter and select the people and applications from which you want to receive notifications while the Focus Mode is turned on. Users can decide to OPT IN/OUT of "time-sensitive notifications".

  • Notification Summary is an optional feature that allows users to select the apps from which they want to stop receiving notifications in real-time but rather store and schedule the notification delivery as a part of the notification summary. Summaries are triggered by the OS based on the time preferences set by the user. The order in which the notifications are displayed depends on the relevancy score associated with the notification.

Relevance Score:

The relevance score is set per notification to indicate the order in which the notifications need to be displayed while viewing the notification summary, with 0 being the lowest and 1 being the highest priority. This was introduced in iOS 15+.

Interruption Levels:

Apple has introduced an interruption-level field as a part of the push notification payload to customize and display notifications based on Focus mode and Notification summary settings:

Interruption Level Payload Value Description Breaks through Focus Overrides Ring/Silent Switch Overrides Scheduled Delivery
Active (Default) active Default Interruption Level. They include information that users wish to be notified on arrival. NO NO NO
Passive (Introduced in iOS 15+) passive They do not light up the screen, no sound or vibration when notification is delivered. These are notifications that users can view at leisure like recommendations. NO NO NO
Time Sensitive (Introduced in iOS 15+) time-sensitive It breaks through Focus mode and overrides notification summary. Includes information that requires users immediate attention like account security , package delivery etc. YES NO YES
Critical critical Requires entitlement from Apple to use Critical interruption level.Urgent information about personal health and public safety that directly impacts people and demands their immediate attention. YES YES YES

Steps to enable Time Sensitive notifications:

  • Enable Time Sensitive Capability from Xcode.( Navigate to Target > + Capability > Time Sensitive Notifications )
  • Add Time Sensitive Notifications in your project Entitlements File and set it to YES.
    Time Sensitive Notifications: YES

Steps to enable Critical Alert notifications:

Note: Critical Alerts cannot be sent by all apps.Only the apps approved for critical alerts entitlement are allowed to send them. Request for entitlement can be submitted here: notifications-critical-alerts-entitlement.

  • Add com.apple.developer.usernotifications.critical-alerts key in your project Entitlements File, change the type to boolean and set it to YES.
  • To implement this you need to pass UNAuthorizationOptionCriticalAlert while registering.

    UNAuthorizationOptions options = UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound;
            
            if (@available(iOS 15.0, *)) {
                options = (options | UNAuthorizationOptionCriticalAlert);
            } else {
                NSLog(@"Critical Alert is not supported below iOS 15.");
            }
            
            [[PushIOManager sharedInstance] registerForNotificationAuthorizations:options categories:nil completionHandler:^(NSError *error, NSString *response) {
                if (nil == error) {
                    NSError *regTrackError = nil;
                    [[PushIOManager sharedInstance] registerApp:&regTrackError completionHandler:^(NSError *regAppError, NSString *response) {
                        if (nil == regAppError) {
                           NSLog(@"Application registered successfully!");
                        } else {
                           NSLog(@"Unable to register application, reason: %@", regAppError.description);
                        }
                    }];
                    if (nil == regTrackError) {
                        NSLog(@"Registration locally stored successfully.");
                    } else {
                        NSLog(@"Unable to store registration, reason: %@", regTrackError.description);
                    }
                }
            }];
    var options: UNAuthorizationOptions = [.alert, .badge, .sound]
            if #available(iOS 15, *) {
                options.insert(.criticalAlert)
            } else {
                print("Critical Alert is not supported below iOS 15.")
            }
            
            PushIOManager.sharedInstance().register(forNotificationAuthorizations: options, categories: nil, completionHandler: { (regTrackError, deviceToken) in
                if (regTrackError == nil) {
                    print("Device Token: \(String(describing: deviceToken))")
                    do {
                        // Register application with SDK.
                        try PushIOManager.sharedInstance().registerApp(completionHandler: { (regError, response) in
                            if (regError == nil) {
                                print("Registration successful")
                            }
                            else {
                                print("Unable to register, reason: \(String(describing: regError))")
                            }
                        })
                    } catch {
                        print("Unable to track registration locally, reason: \(error)")
                    }
                }
            
            })