Push Notifications Not Working in Mobile App Builder

krishnanara
Tera Contributor

Hi Team,

I am trying to set up push notifications for my Mobile App Builder application, but they are not working. I am also unable to find any push notification logs in the sys_push_notification table (Push Logs).

I have completed the following configuration:

  1. Created a new Push Message.
  2. Configured the Push Notification Message Content.
  3. Created a new Notification with Push Message Only = True.
  4. Linked the Push Message field in the Notification to the Push Message created in Step 1.
  5. Enabled notifications in the Now Mobile app.
  6. Added the Push Application (ServiceNow Mobile Application) to the Mobile App Builder.
  7. Verified the cmn_notif_device record for the user and confirmed that Push is enabled for Now Mobile/Agent.
  8. Used the following message content:



(function buildJSON( /*GlideRecord*/ current, /*String*/ message, /*Object*/ attributes) {

    var layoutFieldGenerator = new global.NotificationLayoutFieldGenerator();
    var identifier = layoutFieldGenerator.layoutField(current.sys_class_name, current.sys_id, "number");
    var description = layoutFieldGenerator.layoutField(current.sys_class_name, current.sys_id, "short_description");
    var status = layoutFieldGenerator.layoutField(current.sys_class_name, current.sys_id, "priority");
    var json = {};
    var layoutFieldGenerator = new global.NotificationLayoutFieldGenerator();
    var identifier = layoutFieldGenerator.layoutField(current.sys_class_name, current.sys_id, "number");
    var description = layoutFieldGenerator.layoutField(current.sys_class_name, current.sys_id, "short_description");
    var state = layoutFieldGenerator.layoutField(current.sys_class_name, current.sys_id, "state");

    //set clientType to Agent for ServiceNow Agent, Request for Now Mobile
    var clientType = "Agent";

    //Set ScreenId to the sys_id of the record screen a tap from the notification
    var screenId = "4ff395893bfd03504a7d8c9aa4e45a5a
";  //replaced with the embedded screen sys_id
    var deepLinkGenerator = new global.MobileDeepLinkGenerator(clientType);
    var link = deepLinkGenerator.getFormScreenLink(screenId, current.getTableName(), current.getValue('sys_id'));
    var json = {
        "aps": {
            "sound": "default"
        },
        "Link": link,
        "Layout": {
            "Status": state,
            "Identifier": identifier
        }
    };
    return json;

})(current, message, attributes);

 

 

 

1 REPLY 1

krishnanara
Tera Contributor