Monaca Docs
Search…
Introduction
For release and ad hoc builds, please select the release build option when sending push notifications.

What is a push notification?

Push notification is the information sent from a software application to a computing device without a specific request from the client. There are several types of push notifications such as:
    1.
    Text: a pure text message
    2.
    Badge: a round, red, numerical icon that appears on the top right
    corner of an application icon
    3.
    Sound: a sound file played to alert the user of a new notification
    4.
    JSON Data: data in JSON format used by the application
Currently, sound notifications are not supported in Monaca.
The behavior of an application upon receiving a push notification differs depending on the device's platform and whether the application is opened or closed. In other words, Android notifications are displayed in the upper part of the screen. On the other hand, iOS notifications are displayed as a pop-up dialogue box.

Prerequisite

Monaca Backend is required in order to send push notifications from Monaca Cloud IDE. To add a Monaca Backend to your project, please refer to Getting Started with Monaca Backend.

How to enable push notifications with Monaca

Before starting to use push notifications with Monaca, it is necessary to configure the push notification settings for each platform of your application as follows:
Monaca Debugger can’t receive push notifications. You must build your app to receive push notifications.

How to send push notifications with Monaca

To send push notifications from Monaca Cloud IDE, please proceed as follows:
    1.
    From Monaca Backend window, select Push Notification.
2. From the Push Status & History tab, click Push to App. Then the Push to App dialog will open:
3. Choose the intended OS and fill in the necessary information regarding the push notification as shown below:
Parameter
Description
Title
[Android only] Title of the notification
Message
Text content of the notification
Badge
[iOS only] If you enable this option and set its value to an integer of 1 or greater, the number will be displayed on the top right corner of the app icon.
JSON Data
[Optional] Once the user opens the notification, the application will receive the JSON data. Please refer to How to Receive JSON Data.
4. Click the Add button to send the push notification. It will be first queued and then sent. The delivery might delay if there is high traffic at our Push Server. Please refer to the next section on how to monitor the status of your push notifications.

Monitoring push notification delivery

You can monitor your push notification activities on the Push Status & History page. On this page, you can see information related to each push notification:
Parameter
Description
Platform
The platform of the recipient
Status
The status of the push notification
Date
The date and time of sending the push notification
Devices
The number of successfully sent notifications. It is formatted as Successful Distribution Number/Total Number of Distribution in which Successful Distribution represents the number of successfully sent notifications while the Total Number of Distribution is the total number of sent notifications (see the screenshot below as an example).
Message
The text content of the notification

How to receive JSON data

JSON data within a push notification can be received by monaca.cloud.Push.setHandler function. The JSON data will be passed to data1 and data3 variable within the callback. Here is an example of how to use this function:
1
monaca.cloud.Push.setHandler(function(data1, data2, data3) {
2
// JSON data within push notification
3
console.log(JSON.stringify(data1));
4
console.log(JSON.stringify(data2));
5
console.log(JSON.stringify(data3));
6
});
Copied!
The data2 and data3 can get coldstart and foreground information to check the reception status of push notifications.
The callback function will be called after the page is loaded. However, there may be some time lag. Therefore, please be cautious about this.
Last modified 2mo ago