Example


A snippet below contains JavaScript that makes use of the Notifications API functionality.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
window.onLaunchboxLoaded = function() { 
  // To receive the initial notification, attach a handler in onLaunchboxLoaded(). 
  launchbox.Notifications.onNotificationReceive.bind(notificationHandler); 
 
  // Create a category for receiving new mails with Reply and Snooze buttons. 
  var mailCategory = new NotificationCategory('mail'); 
  mailCategory.setActions( 
    new NotificationAction('reply', 'Reply'), 
    new NotificationAction('snooze', 'Snooze'
  ); 
 
  // Categories can be registered at any moment before notification is received. 
  // It doesn't have to be done inside onLaunchboxLoaded(). 
  launchbox.Notifications.registerCategory(mailCategory); 
 
  // Registration can be done at any time, but both Apple and Google recommend doing it on every app start. 
  launchbox.Notifications.registerForPushNotifications() 
    .then(function(token) { 
      ... 
    }); 
}; 
 
 
// Sample handler. 
var notificationHandler = function(type, payload, actionId) { 
  if (actionId === "reply") { 
    ... 
  } else if (actionId === "snooze") { 
    ... 
  
};

Related topics

Notifications
Legal notice | Copyright © 2015 and Confidential to Pegasystems Inc. All rights reserved. | Feedback
Advanced...