Push Notification

The following JavaScript API is used to handle the push notifications.

Method Description
monaca.cloud.Push.setHandler() Set JavaScript handler when receiving push notification

Push.setHandler()

Set push handler which is called when an application receives a push notification.

monaca.cloud.Push.setHandler(callback: Function) : void

Parameter

Name Type Description
callback Function Callback function to handle incoming push notification. Additional JSON data will be set at the first and third argument.

Return Value

  • None

Example

The following code shows a simple function to display the data received from the push notification in the console.log.

monaca.cloud.Push.setHandler(function(data1, data2, data3) {
  // JSON data within push notification
  console.log(JSON.stringify(data1));
  console.log(JSON.stringify(data2));
  console.log(JSON.stringify(data3));
});

See Also: