Push Notification

For release and ad-hoc builds on Cordova 6.2 platform, please select the release build option when sending push notifications.

Below are Monaca Backend Management APIs for Push Notifications.

Method Description
Push.send() Send Push Notification
Push.status() Get Push Notification Status

Push.send()

Send push notification to applications.

Push.send()

Parameter

Name Type Description
pushProjectId String Push Project ID
platform String User’s platform which can be "android" or "ios"
target String Type of end user which is "app".
buildType String Build type of the application which can be "debug" , "release" or "adhoc".
title String Title (Android only)
message String Message to send
badge Number Badge (iOS only)
extra_json JSON Object JSON Data
userOidList Array of String [Optional] Filter target users by their IDs.
userQuery String [Optional] Filter target users by a MonaQL query for user properties. For example: 'country == "US" && age = 20'.
userQueryBindParams Array [Optional] Replace the placeholders in userQuery by its values. For example: ["US", 20] when userQuery is 'country == ? && age = ?'.
deviceIdList Array of String [Optional] Filter target devices by its IDs.
Please note that deviceIdList, userOidList and userQuery cannot be used at the same time.

Return Value

Name Type Description
queueIdList Array A list of push queue id

Errors Code

Errors are returned as Error object.

Code Description
-32602 Invalid params

Push.status()

Get push notification status.

Push.status(pushProjectId: String, queueId: String)

Parameter

Name Type Description
pushProjectId String Push Project ID
queueId String Push queue ID (get this id from queueIdList)

Return Value

Name Type Description
status String Status (finish, etc.)
numTarget Number Number of all recipients
numPushed Number Number of success recipients
numFailed Number Number of failed recipients
createdAt TimeUnit Created time
pushStartedAt TimeUnit Started time
pushFinishedAt TimeUnit Finished time (regardless of success or failure)

Errors Code

Errors are returned as Error object.

Code Description
-32602 Invalid params

Push Project ID

Push project ID is an unique identifier for sending push notification to your app. You can easily find this ID with the following instruction:

  1. Go to Monaca Backend by clicking on a Cloud icon in Monaca Cloud IDE.

  2. Then, click on Setting icon and choose Backend Settings (See below screenshot)

  3. You will see a Backend Settings panel on the right side of the screen. Next, click on Push Notification. Scroll down to the bottom of this page to see Push project ID of the current application.

See Also: