Mobile App Push NotificationsDescription<!-- .markdown-body { -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; line-height: 1.5; color: #24292e; font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 16px; line-height: 1.5; word-wrap: break-word; } .markdown-body { box-sizing: border-box; min-width: 200px; /*max-width: 2000px;*/ margin: 0 auto; padding: 45px; font-family: -apple-system, 'Helvetica Neue', 'Helvetica', 'Avenir', 'Lucida Grande'; } .markdown-body .pl-c { color: #969896; } .markdown-body .pl-c1, .markdown-body .pl-s .pl-v { color: #0086b3; } .markdown-body .pl-e, .markdown-body .pl-en { color: #795da3; } .markdown-body .pl-smi, .markdown-body .pl-s .pl-s1 { color: #333; } .markdown-body .pl-ent { color: #63a35c; } .markdown-body .pl-k { color: #a71d5d; } .markdown-body .pl-s, .markdown-body .pl-pds, .markdown-body .pl-s .pl-pse .pl-s1, .markdown-body .pl-sr, .markdown-body .pl-sr .pl-cce, .markdown-body .pl-sr .pl-sre, .markdown-body .pl-sr .pl-sra { color: #183691; } .markdown-body .pl-v, .markdown-body .pl-smw { color: #ed6a43; } .markdown-body .pl-bu { color: #b52a1d; } .markdown-body .pl-ii { color: #f8f8f8; background-color: #b52a1d; } .markdown-body .pl-c2 { color: #f8f8f8; background-color: #b52a1d; } .markdown-body .pl-c2::before { content: "^M"; } .markdown-body .pl-sr .pl-cce { font-weight: bold; color: #63a35c; } .markdown-body .pl-ml { color: #693a17; } .markdown-body .pl-mh, .markdown-body .pl-mh .pl-en, .markdown-body .pl-ms { font-weight: bold; color: #1d3e81; } .markdown-body .pl-mq { color: #008080; } .markdown-body .pl-mi { font-style: italic; color: #333; } .markdown-body .pl-mb { font-weight: bold; color: #333; } .markdown-body .pl-md { color: #bd2c00; background-color: #ffecec; } .markdown-body .pl-mi1 { color: #55a532; background-color: #eaffea; } .markdown-body .pl-mc { color: #ef9700; background-color: #ffe3b4; } .markdown-body .pl-mi2 { color: #d8d8d8; background-color: #808080; } .markdown-body .pl-mdr { font-weight: bold; color: #795da3; } .markdown-body .pl-mo { color: #1d3e81; } .markdown-body .pl-ba { color: #595e62; } .markdown-body .pl-sg { color: #c0c0c0; } .markdown-body .pl-corl { text-decoration: underline; color: #183691; } .markdown-body .octicon { display: inline-block; vertical-align: text-top; fill: currentColor; } .markdown-body a { background-color: transparent; -webkit-text-decoration-skip: objects; } .markdown-body a:active, .markdown-body a:hover { outline-width: 0; } .markdown-body strong { font-weight: inherit; } .markdown-body strong { font-weight: bolder; } .markdown-body h1 { font-size: 2em; margin: 0.67em 0; } .markdown-body img { border-style: none; } .markdown-body svg:not(:root) { overflow: hidden; } .markdown-body code, .markdown-body kbd, .markdown-body pre { font-family: monospace, monospace; font-size: 1em; } .markdown-body hr { box-sizing: content-box; height: 0; overflow: visible; } .markdown-body input { font: inherit; margin: 0; } .markdown-body input { overflow: visible; } .markdown-body [type="checkbox"] { box-sizing: border-box; padding: 0; } .markdown-body * { box-sizing: border-box; } .markdown-body input { font-family: inherit; font-size: inherit; line-height: inherit; } .markdown-body a { color: #0366d6; text-decoration: none; } .markdown-body a:hover { text-decoration: underline; } .markdown-body strong { font-weight: 600; } .markdown-body hr { height: 0; margin: 15px 0; overflow: hidden; background: transparent; border: 0; border-bottom: 1px solid #dfe2e5; } .markdown-body hr::before { display: table; content: ""; } .markdown-body hr::after { display: table; clear: both; content: ""; } .markdown-body table { border-spacing: 0; border-collapse: collapse; } .markdown-body td, .markdown-body th { padding: 0; } .markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { margin-top: 0; margin-bottom: 0; } .markdown-body h1 { font-size: 32px; font-weight: 600; } .markdown-body h2 { font-size: 24px; font-weight: 600; } .markdown-body h3 { font-size: 20px; font-weight: 600; } .markdown-body h4 { font-size: 16px; font-weight: 600; } .markdown-body h5 { font-size: 14px; font-weight: 600; } .markdown-body h6 { font-size: 12px; font-weight: 600; } .markdown-body p { margin-top: 0; margin-bottom: 10px; } .markdown-body blockquote { margin: 0; } .markdown-body ul, .markdown-body ol { padding-left: 0; margin-top: 0; margin-bottom: 0; } .markdown-body ol ol, .markdown-body ul ol { list-style-type: lower-roman; } .markdown-body ul ul ol, .markdown-body ul ol ol, .markdown-body ol ul ol, .markdown-body ol ol ol { list-style-type: lower-alpha; } .markdown-body dd { margin-left: 0; } .markdown-body code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 12px; } .markdown-body pre { margin-top: 0; margin-bottom: 0; font: 12px "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; } .markdown-body .octicon { vertical-align: text-bottom; } .markdown-body .pl-0 { padding-left: 0 !important; } .markdown-body .pl-1 { padding-left: 4px !important; } .markdown-body .pl-2 { padding-left: 8px !important; } .markdown-body .pl-3 { padding-left: 16px !important; } .markdown-body .pl-4 { padding-left: 24px !important; } .markdown-body .pl-5 { padding-left: 32px !important; } .markdown-body .pl-6 { padding-left: 40px !important; } .markdown-body::before { display: table; content: ""; } .markdown-body::after { display: table; clear: both; content: ""; } .markdown-body>*:first-child { margin-top: 0 !important; } .markdown-body>*:last-child { margin-bottom: 0 !important; } .markdown-body a:not([href]) { color: inherit; text-decoration: none; } .markdown-body .anchor { float: left; padding-right: 4px; margin-left: -20px; line-height: 1; } .markdown-body .anchor:focus { outline: none; } .markdown-body p, .markdown-body blockquote, .markdown-body ul, .markdown-body ol, .markdown-body dl, .markdown-body table, .markdown-body pre { margin-top: 0; margin-bottom: 16px; } .markdown-body hr { height: 0.25em; padding: 0; margin: 24px 0; background-color: #e1e4e8; border: 0; } .markdown-body blockquote { padding: 0 1em; color: #6a737d; border-left: 0.25em solid #dfe2e5; } .markdown-body blockquote>:first-child { margin-top: 0; } .markdown-body blockquote>:last-child { margin-bottom: 0; } .markdown-body kbd { display: inline-block; padding: 3px 5px; font-size: 11px; line-height: 10px; color: #444d56; vertical-align: middle; background-color: #fafbfc; border: solid 1px #c6cbd1; border-bottom-color: #959da5; border-radius: 3px; box-shadow: inset 0 -1px 0 #959da5; } .markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { margin-top: 24px; margin-bottom: 16px; font-weight: 600; line-height: 1.25; } .markdown-body h1 .octicon-link, .markdown-body h2 .octicon-link, .markdown-body h3 .octicon-link, .markdown-body h4 .octicon-link, .markdown-body h5 .octicon-link, .markdown-body h6 .octicon-link { color: #1b1f23; vertical-align: middle; visibility: hidden; } .markdown-body h1:hover .anchor, .markdown-body h2:hover .anchor, .markdown-body h3:hover .anchor, .markdown-body h4:hover .anchor, .markdown-body h5:hover .anchor, .markdown-body h6:hover .anchor { text-decoration: none; } .markdown-body h1:hover .anchor .octicon-link, .markdown-body h2:hover .anchor .octicon-link, .markdown-body h3:hover .anchor .octicon-link, .markdown-body h4:hover .anchor .octicon-link, .markdown-body h5:hover .anchor .octicon-link, .markdown-body h6:hover .anchor .octicon-link { visibility: visible; } .markdown-body h1 { padding-bottom: 0.3em; font-size: 2em; border-bottom: 1px solid #eaecef; } .markdown-body h2 { padding-bottom: 0.3em; font-size: 1.5em; border-bottom: 1px solid #eaecef; } .markdown-body h3 { font-size: 1.25em; } .markdown-body h4 { font-size: 1em; } .markdown-body h5 { font-size: 0.875em; } .markdown-body h6 { font-size: 0.85em; color: #6a737d; } .markdown-body ul, .markdown-body ol { padding-left: 2em; } .markdown-body ul ul, .markdown-body ul ol, .markdown-body ol ol, .markdown-body ol ul { margin-top: 0; margin-bottom: 0; } .markdown-body li>p { margin-top: 16px; } .markdown-body li+li { margin-top: 0.25em; } .markdown-body dl { padding: 0; } .markdown-body dl dt { padding: 0; margin-top: 16px; font-size: 1em; font-style: italic; font-weight: 600; } .markdown-body dl dd { padding: 0 16px; margin-bottom: 16px; } .markdown-body table { display: block; width: 100%; overflow: auto; } .markdown-body table th { font-weight: 600; } .markdown-body table th, .markdown-body table td { padding: 6px 13px; border: 1px solid #dfe2e5; } .markdown-body table tr { background-color: #fff; border-top: 1px solid #c6cbd1; } .markdown-body table tr:nth-child(2n) { background-color: #f6f8fa; } .markdown-body img { max-width: 100%; box-sizing: content-box; background-color: #fff; } .markdown-body code { padding: 0; padding-top: 0.2em; padding-bottom: 0.2em; margin: 0; font-size: 85%; background-color: rgba(27,31,35,0.05); border-radius: 3px; } .markdown-body code::before, .markdown-body code::after { letter-spacing: -0.2em; content: "\00a0"; } .markdown-body pre { word-wrap: normal; } .markdown-body pre>code { padding: 0; margin: 0; font-size: 100%; word-break: normal; white-space: pre; background: transparent; border: 0; } .markdown-body .highlight { margin-bottom: 16px; } .markdown-body .highlight pre { margin-bottom: 0; word-break: normal; } .markdown-body .highlight pre, .markdown-body pre { padding: 16px; overflow: auto; font-size: 85%; line-height: 1.45; background-color: #f6f8fa; border-radius: 3px; } .markdown-body pre code { display: inline; max-width: auto; padding: 0; margin: 0; overflow: visible; line-height: inherit; word-wrap: normal; background-color: transparent; border: 0; } .markdown-body pre code::before, .markdown-body pre code::after { content: normal; } .markdown-body .full-commit .btn-outline:not(:disabled):hover { color: #005cc5; border-color: #005cc5; } .markdown-body kbd { display: inline-block; padding: 3px 5px; font: 11px "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; line-height: 10px; color: #444d56; vertical-align: middle; background-color: #fcfcfc; border: solid 1px #c6cbd1; border-bottom-color: #959da5; border-radius: 3px; box-shadow: inset 0 -1px 0 #959da5; } .markdown-body :checked+.radio-label { position: relative; z-index: 1; border-color: #0366d6; } .markdown-body .task-list-item { list-style-type: none; } .markdown-body .task-list-item+.task-list-item { margin-top: 3px; } .markdown-body .task-list-item input { margin: 0 0.2em 0.25em -1.6em; vertical-align: middle; } .markdown-body hr { border-bottom-color: #eee; } --> ServiceNow Mobile App Push Notifications Overview This discussion applies to the ServiceNow native mobile apps for iOS and Android. For information on integrating notifications with a custom mobile application, please see Setup Push Notifications for a Custom Push App. Push notification payloads sent from an instance to the ServiceNow mobile apps support the following attributes: Message: The message text to display in the notification alert.Notification category: An optional category used to determine which predefined actions (buttons) should be displayed and whether the mobile app should be opened in response to an action.Scripts: The script to run when a specific button is tapped. Scripts are stored in the sys_push_notif_act_script table.Record: An optional record to open in response to the notification.Web Path: An optional web path or URL to open in response to the notification. This takes precedence over the record attribute. Supported Categories A notification category is used to determine which predefined actions (buttons) should be displayed and whether the mobile app should be opened in response to an action. Note: Custom button titles are not supported by the ServiceNow mobile apps. A notification category is the only way to specify predefined button titles. Notification categories are not stored on the instance and can not be modified. The ServiceNow mobile apps support the following categories: Category IdentifierButton 1 TitleButton 1 IdentifierButton 1 ModeButton 2 TitleButton 2 IdentifierButton 2 Modeapprove_reject_foregroundApproveapprove_foregroundforegroundRejectreject_foregroundforegroundapprove_reject_backgroundApproveapprove_backgroundbackgroundRejectreject_backgroundbackgroundyes_no_foregroundYesyes_foregroundforegroundNono_foregroundforegroundyes_no_backgroundYesyes_backgroundbackgroundNono_backgroundbackgroundaccept_decline_foregroundAcceptaccept_foregroundforegroundDeclinedecline_foregroundforegroundaccept_decline_backgroundAcceptaccept_backgroundbackgroundDeclinedecline_backgroundbackground Generating Payloads Push Notification Message Content records are stored in the sys_push_notif_msg_content table. These records are used to generate push notification payloads. Below are example scripts that demonstrate how to generate payloads with different behavior and buttons. Record Payload This payload will open the app to the current record when the notification is opened. The notification will not have any buttons. (function buildJSON(/*GlideRecord*/ current, /*String*/ message, /*Object*/ attributes) { var json = {}; json = { "aps" : { "sound" : "default" }, "record" : { "table" : current.getTableName(), "sys_id" : current.sys_id } }; return json; })(current, message, attributes); Web Path Payload This payload will open the app to a custom web path or URL when the notification is opened. The notification will not have any buttons. (function buildJSON(/*GlideRecord*/ current, /*String*/ message, /*Object*/ attributes) { var json = {}; json = { "aps" : { "sound" : "default" }, "web_path" : "$vtb.do" }; return json; })(current, message, attributes); Approve / Reject Foreground Payload This payload will open the app to the current record when the notification is opened or a button is tapped. The notification will have "Approve" and "Reject" buttons that will trigger a script in the foreground and cause the app to open. (function buildJSON(/*GlideRecord*/ current, /*String*/ message, /*Object*/ attributes) { var json = {}; json = { "aps" : { "sound" : "default", "category" : "approve_reject_foreground" }, "record" : { "table" : current.getTableName(), "sys_id" : current.sys_id }, "scripts" : {"approve_foreground" : "333ecc6253020200601fa3fc9ec58727", "reject_foreground" : "632ecc6253020200601fa3fc9ec58708" } }; return json; })(current, message, attributes); Yes / No Background Payload This payload will open the app to the current record when the notification is opened, but not when a button is tapped. The notification will have "Yes" and "No" buttons that will trigger a script in the background without opening the app. (function buildJSON(/*GlideRecord*/ current, /*String*/ message, /*Object*/ attributes) { var json = {}; json = { "aps" : { "sound" : "default", "category" : "yes_no_background" }, "record" : { "table" : current.getTableName(), "sys_id" : current.sys_id }, "scripts" : {"yes_background" : "333ecc6253020200601fa3fc9ec58727", "no_background" : "632ecc6253020200601fa3fc9ec58708" } }; return json; })(current, message, attributes);