Sending a Push Notification

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

ParameterDescription
X-Appery-Push-API-KeyHeader. Unique key issued by server that allows push notifications to be sent.
expirationTimeTime stamp in UTC TZ, when the provider (Apple, Google, etc.) should stop trying to send notification (if device is unavailable).
filterParameter used for filtering devices.
optionsObject with push notification sending options.
payloadObject that contains text message and badge.
scheduleObject that contains data for scheduling.
statusIndicates 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 StatusCodeDescription
404PNMM004Master Key: not found
400PNMM017Message can’t be empty
400PNMM021There are nobody who will be able to receive this message
400PNMM056Database with id='<db_id>' is not connected to push application
400PNMM062Badge cannot be negative
404PNMM082iOS Push certificate is not set
404PNMM084Android API key is not set
404PNMM085iOS Push certificate password is not set
400PNMM088Push notification data is too big
400PNMM089Firebase Admin SDK JSON File is not set
400PNMM101Empty scheduled time
400PNMM102Empty time zone
400PNMM116Push notification payload should include at least one of this fields: "message", "title", "custom data"
400PNMM117Can't authenticate to Google. Please check Firebase Admin SDK JSON File
400PNMM960Specified 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