Configure code for critical alerts
Summarize
Summary of Configure code for critical alerts
This guide explains how ServiceNow customers can configure push notifications as critical alerts for both iOS and Android devices. It details the necessary JSON code additions to the push message content area to ensure notifications are treated as critical alerts, including specific considerations for the IT Service Management (ITSM) business unit.
Show less
Critical alerts override usual notification behaviors by playing distinctive alert sounds and waking devices, which is crucial for urgent notifications in enterprise environments.
Key Features
- Platform-specific JSON configuration: Different JSON code snippets are required for iOS and Android to activate critical alerts effectively.
- Android critical alert activation: Adding the
priority: "high"key in the JSON triggers Android devices to wake up and display the critical alert. - iOS critical alert configuration: The JSON includes a sound object with parameters
critical: 1, alert tonename, andvolumeto define the alert behavior. - Customizable alert sounds: Acceptable sound files like
NotificationAlert-1.cafprovide dramatic and powerful tones. If no name is specified, the system defaults to the app or device ringtone. - Volume control: Sound volume ranges from 0.1 (quietest) to 1.0 (loudest) to adjust alert loudness.
- ITSM CriticalPushPayloadBuilder script include: For ITSM users, a reusable server-side script include automates critical alert JSON generation. Modifications require changing input parameters in the script, but changes impact all ITSM implementations and may be overwritten by plugin upgrades.
Important Platform Behaviors and Limitations
- On certain Android devices like OnePlus and Oppo, hardware-controlled ringer modes or Do Not Disturb settings can affect critical alert behavior, such as limiting sound override capabilities or temporarily disabling DND during alert playback.
- Critical alerts are unsupported on Android Private Space (Android 15) and devices managed by Mobile Device Management (MDM) solutions like Microsoft Intune.
Practical Application
To implement critical alerts in ServiceNow push notifications:
- Add the appropriate JSON code block to the push message content area, including Android priority keys and iOS sound parameters.
- For ITSM customers using the CriticalPushPayloadBuilder script include, verify if it is already present to avoid redundant configuration.
- Customize alert sounds and volume as needed, understanding that changes to the ITSM script include affect all ITSM users and may be reverted on upgrades.
This configuration ensures that critical alerts reliably notify users with high-priority sounds and device wake behavior, enhancing incident response and operational awareness.
You can make a push notification into a critical alert with the addition of some JSON code. Different JSON code is used for iOS and Android operating systems and for the ITSM business unit.
When creating critical alert notifications, you need the code structure of a push notification message as well as the required JSON code that defines the notification as a critical alert. You add this code in the Push message content area. For more information, see Mobile critical alerts.
On the Android platform, when a user receives a critical alert on certain phone types, they may experience the following device behavior:
- OnePlus devices with hardware-controlled ringer mode:
- On devices like OnePlus where the ringer mode is controlled by a physical switch, the app might not be able to override the notification sound volume if the device is set to silent or vibrate mode.
- OnePlus or Oppo device Do Not Disturb mode behavior:
- On certain devices, like Oppo and OnePlus, if Do Not Disturb (DND) mode is enabled, the DND setting might be temporarily turned off until the critical notification sound has finished playing.
- The Android Private Space feature that was introduced in Android 15.
- Android devices that are managed by Mobile Device Management (MDM) software. For example, Microsoft Intune.
Critical alert JSON to activate Android operating systems
json["sncGoogleKeys"] = {
"android": {
"priority": "high"
},
"priority": "high"
};
Critical alert JSON for all operating systems
The following JSON must be added so that a notification behaves as a critical alert.
var json = {};
json["aps"] = {
"sound": {
"critical": 1,
"name": "NotificationAlert-1.caf",
"volume": 1.0
}
};
- The critical parameter defines the notification as a critical alert.
1means the critical alert is active,0means the critical alert is inactive. - The name parameter is the name of the tone that is activated when a critical alert is sent. Some tones for critical alerts are listed in the table. For a complete list, see Configure sounds for push notifications.
Accepted file name values Tone rhythm NotificationAlert-2.cafDramatic NotificationAlert-2-Short.cafDramatic NotificationAlert-9.cafDramatic, Powerful NotificationAlert-9-Short.cafDramatic, Powerful NotificationAlert-10.cafDramatic, Suspenseful NotificationAlert-10-Short.cafDramatic, Suspenseful Note:If a name value isn’t defined, the system uses the application’s default ringtone. If an application doesn't have a defined ringtone, then the system uses the device's default ringtone. - The volume parameter defines the volume of the critical alert sound. The range is from
0.1as the quietest to1.0as the loudest.
Example JSON code block for critical alert
The following is a complete example block of JSON code that you must add and configure to activate a critical alert for Android and iOS devices.
json["sncGoogleKeys"] = {
"android": {
"priority": "high"
},
"priority": "high"
};
json["aps"]["sound"] = {
"critical": 1,
"name": "NotificationAlert-1.caf",
"volume": 1.0
};IT Service Management (ITSM) CriticalPushPayloader script include
CriticalPushPayLoadBuilder, created by the ITSM business unit. If so, then no additional configuration is required for critical alerts. Script includes are reusable server-side script logic that define a function or class.
CriticalPushPayLoadBuilder is a script include that contains functions to support critical alerts. The call of the script includes looks like this: CriticalPushPayloadBuilder (current, json,
attributes).buildJSON()Volume or Name parameters, or change the alert from critical to non-critical, you need to access the function
parameters that the script include is getting as inputs.Changing the value of the critical alert script include affects all ITSM implementations of the script include. Similarly, an ITSM plugin upgrade could override your changes to your script include.