Sending a Push Notification mesage.
You can send a Push Notification message to one or more devices (iOS or Android) that installed your app by making a request to the following endpoint:
https://api.appery.io/rest/push/msg
X-Appery-Push-API-Key is a required header for this service, you can find this key in the Settings section in Apps > Push Notifications tab. As this is a POST method service, non-header parameters should be passed as request body.
If the push notification is scheduled the server returns HTTP 200 and a list of the saved push notifications, otherwise the server returns with a HTTP 204 NO CONTENT status, even if no messages were sent or delivered. #Parameters summary
Parameter | Description |
---|---|
X-Appery-Push-API-Key |
Header. Unique key issued by server that allows push notifications to be sent. |
expirationTime |
Time stamp in UTC TZ, when the provider (Apple, Google, etc.) should stop trying to send notification (if device is unavailable). |
filter |
Parameter used for filtering devices. |
options |
Object with push notification sending options. |
payload |
Object that contains text message and badge. |
schedule |
Object that contains data for scheduling. |
status |
Indicates sent push notification instantly or schedule. |
filter is an optional parameter. With the filter being empty, push notifications will be sent to all devices. schedule is an optional parameter for immediate push notifications.
#Possible errors
HTTP Status | Code | Description |
---|---|---|
404 |
PNMM004 |
Master Key: <pushAPIKey> not found |
400 |
PNMM017 |
Message can’t be empty |
400 |
PNMM021 |
There are nobody who will be able to receive this message |
400 |
PNMM056 |
Database with id=' |
400 |
PNMM062 |
Badge cannot be negative |
404 |
PNMM082 |
iOS Push certificate is not set |
404 |
PNMM084 |
Android API key is not set |
404 |
PNMM085 |
iOS Push certificate password is not set |
400 |
PNMM088 |
Push notification data is too big |
400 |
PNMM089 |
Firebase Admin SDK JSON File is not set |
400 |
PNMM101 |
Empty scheduled time |
400 |
PNMM102 |
Empty time zone |
400 |
PNMM116 |
Push notification payload should include at least one of this fields: "message", "title", "custom data" |
400 |
PNMM117 |
Can't authenticate to Google. Please check Firebase Admin SDK JSON File |
400 |
PNMM960 |
Specified brand is not valid |
Example
This examples show how to send a Push Notification message right away. To send a message right away the status parameter is set to sent.
curl -X POST
-H "X-Appery-Push-API-Key: 2cc37fde-7d34-48ef-a13e-816e9e93ef2d"
-H "Content-Type: application/json"
-d '{
"payload":{
"message":"Hey!",
"badge":1
},
"status":"sent"
}'
https://api.appery.io/rest/push/msg