{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":34725,"path":"mobile/config-push-notification-message-content.md","title":"Configure push notification message content","bundle":null,"doc_type":null,"release":"australia","body":"\n# Configure push notification message content\n\nConfigure push notification message content and select which mobile application receives notifications. You can configure critical alert notifications, customize the message appearance, and determine the deep link used when users tap the notification.\n\n## Before you begin\n\nTo configure push notification message content, you must generate a deep link using the mobile deep link generator. For more information, see [Deep linking for mobile](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/mobile/deep-link-mobile.md).\n\nRole required: admin\n\n## About this task\n\nComplete the Push Message Content form to:\n\n-   Name the notification\n-   Select the mobile app that the notification is sent to\n-   Optionally customize the appearance of the notification message\n-   Determine the deep link used when users tap the notification\n\nPush notification message content supports up to three additional fields. If these fields are used as optional text slots, the slots can display fields from the source record.\n\n**Note:** The text slots are fixed on the mobile app, so you cannot change their location or size. Each slot maps to a `Status`, `Identifier`, and `Description` within the JSON object in the push notification message content script.\n\nMobile UI styles are also available for additional fields. For more information around styling, see [Mobile UI styles](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/mobile/mobile-ui-styles.md).\n\n## Procedure\n\n1.  Navigate to **All** &gt; **System Notification** &gt; **Push** &gt; **Push Message Content**.\n\n2.  Select **New**.\n\n3.  In the Push Message Content form, fill in the following fields:\n\n<table id=\"table_fbr_1vm_5pb\"><thead><tr><th>\n\nField\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nName\n\n</td><td>\n\nString value for this record.**Note:** This name is not visible in the notification, it is only a reference for use during configuration.\n\n</td></tr><tr><td>\n\nPush app\n\n</td><td>\n\nReferences the mobile app you want to send a notification to.-   Use ServiceNow mobile Application for Mobile Agent.\n-   Use ServiceNow Request Application for Now Mobile app.\n\n\n</td></tr><tr><td>\n\nPush Message Generation\n\n</td><td>\n\nThe script block that contains the notification link. In the script block, the JSON object must return a link and a `Link` key must exist. The key should have a corresponding deep link value generated through the mobile deep link generator.\n\n</td></tr></tbody>\n</table>    This example shows the completed form and a JSON object with the appropriate `Link` key and a corresponding deep link value.\\[Omitted image \"mobile-push-content-deep-link-sample.png\"\\] Alt text: Push Message Content form with all of the fields completed and an example deep link indicated by Link key.\n\n4.  Add additional fields to the notification content, such as a text slot.\n\n    In the **Push Message Generation** script block, create a layout field object for each field.\n\n    1.  Instantiate a notification layout object.\n\n        ```\n        var layoutGen = new global.NotificationLayoutFieldGenerator();\n        ```\n\n    2.  Use the notification layout script and include the global application scope to generate layout fields.\n\n        To learn more about script includes, see [Script Includes](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/api-reference/scripts/c_ScriptIncludes.md).\n\n        **Note:** Do not modify the notification layout generator script include.\n\n    3.  Create the layout field.\n\n        Each layout field requires a `Table`, `Sys_Id`, and a `Column`.\n\n        **Note:** The `Table` and `Sys_Id` values should come directly from the current record using `current.getTableName()` and `current.sys_id`. The `Column` value must exist for the desired table and match the dictionary column name exactly.\n\n        ```\n        var text_01 = layoutGen.layoutField(current.getTableName(), current.sys_id, \"priority\");\n        ```\n\n    4.  Pass the layout fields into the original JSON object as another object.\n\n        The mobile applications listen for the optional `Layout` key, which is an object that contains the desired additional fields. In the `Layout` object, associate each additional field with the `Status`, `Identifier`, or `Description` keys. The following example is available as a reference.\n\n        ```json\n        (function buildJSON( /*GlideRecord*/ current, /*String*/ message, /*Object*/ attributes) { \n        \n            var layoutGen = new global.NotificationLayoutFieldGenerator(); \n            var text_01 = layoutGen.layoutField(current.getTableName(), current.sys_id, \"priority\"); \n            var text_02 = layoutGen.layoutField(current.getTableName(), current.sys_id, \"state\"); \n            var text_03 = layoutGen.layoutField(current.getTableName(), current.sys_id, \"short_description\"); \n        \n            var deepLinkGenerator = new global.MobileDeepLinkGenerator(\"Request\"); \n            var link = deepLinkGenerator.getFormScreenLink(\"b71040b1533a33007bc2ddeeff7b1221\", current.getTableName(), current.getValue(\"sys_id\")); \n        \n            var json = { \n        \n                \"Link\": link, \n        \n                \"Layout\": { \n        \n                    \"Status\": text_01, \n        \n                    \"Identifier\": text_02, \n        \n                    \"Description\": text_03 \n        \n                } \n        \n            }; \n        \n            return json;\n        \n        })(current, message, attributes);\n        ```\n\n5.  Add a customized notification title.\n\n    If you don't add a customized notification title, the notification displays the default mobile app name.\n\n    \\[Omitted image \"mob-cust-not-tit-with-callout.png\"\\] Alt text: Image showing the difference between a standard notification message title that displays the mobile app name and a custom title that describes the notification.\n\n    In the **Push Message Generation** script block, add the following example code in the `json` section:\n\n    ```\n    var json= {};\n    var msg_title  = \"System updates!\";\n    json= {\n      \"android_title\" : msg_title,\n      \"aps\": {\n        \"alert\": {\n          \"title\": msg_title,\n        }\n      }\n    \n    ```\n\n    The elements in the sample JSON code are as follows:\n\n    -   The **msg\\_title** variable called `System updates!` is the notification title name that applies to both iOS and Android.\n    -   The node`json[\"android_title\"]` is the variable for Android.\n    -   The node `json[\"aps\"][\"alert\"][\"title\"]` is the variable for iOS.\n6.  Add the following code to activate Android devices to wake up, so that notifications can be triggered.\n\n    As users use both iOS and Android devices you must add this code. The JSON entry in the code is a returned dictionary name value from the scripting.\n\n    Android specific fields that control message delivery are supported under **sncGoogleKeys**. For more information, see [Firebase Cloud Messaging HTTP Protocol](https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream-http-messages-json).\n\n    **Note:** The **priority** parameter is set to `high` to wake up Android devices, if a device is in sleep mode. This parameter helps to deliver critical alerts to end users.\n\n    ```\n    json[\"sncGoogleKeys\"] = {\n        \"priority\": \"high\",\n        \"android\": {\n          \"priority\": \"high\"\n        }\n    }\n    \n    ```\n\n7.  Select **Update**.\n\n\n## Result\n\nYou created a push notification message content record that contains a deep link.\n\n## What to do next\n\nAfter configuring push notification message content, it must be paired with a push notification message record. For more information on configuring a push notification message, see [Configure a push notification message](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/mobile/configure-push-notification-message.md).\n\n**Parent Topic:**[Mobile push notification components](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/mobile/configure-mobile-push-notifications.md)\n\n"}}