Jon Haider
Posts: 0
Joined: Thu Oct 16, 2014 2:53 pm

Can we send a custom payload for Push notifications in appery?

I'd like to send push notifications from the server, and was wondering if Appery supports custom payload json objects. I know that apple allows this, but their dictionary is different than what is done on appery (see here)

For example, instead of only sending:
pre
var payload = {
"message": "hello world!",
"badge": 1
};
/pre

I'd like to send:

pre
var payload = {
"message": "hello world!",
"badge": 1,
"type": 4 //notice the type
};
/pre

This way, on the device end, I can identify the notification "type" and make the app perform some action accordingly.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Can we send a custom payload for Push notifications in appery?

Hi Jon,

Unfortunatly nope.

Only content that could be send to device is "message".

Regards.

Jon Haider
Posts: 0
Joined: Thu Oct 16, 2014 2:53 pm

Can we send a custom payload for Push notifications in appery?

Thanks Yurii, but is this an Appery limitation, or is that not feasible in general?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Can we send a custom payload for Push notifications in appery?

Hi Jon,

i can not tell you exactly about it.. But it seems some push technologies could receive additional information.

For example: http://stackoverflow.com/questions/11...

Unfortunatly you can not pass data to device through PUSH notification with Appery.io platform. This technology designed only to alert user about "some" event.. Further processing should be implemented with custom logic.

Here is a brief plan how to implement it in Appery.io:

  1. Create new db collection "Events" (deviceid: string, data: object )

  2. When you send PUSH, add new row into this collection. (with data you need like id of the message to read )

  3. When device get push notification - device get all records with current "deviceid" filter.

  4. Make action stored in the "data" column of the received row. (for example: navigate to page - "messages" and load message with certain id.

    Regards.

David Quigley
Posts: 0
Joined: Wed Jun 01, 2016 1:15 pm

Can we send a custom payload for Push notifications in appery?

Is this information still current? Appery allows us to add custom parameters to notifications. How do we go about reading those custom parameters from the app?

Jon Haider
Posts: 0
Joined: Thu Oct 16, 2014 2:53 pm

Can we send a custom payload for Push notifications in appery?

The customData should be a JSON object with some keys and values in it. You can access these keys directly from within arguments[1].additionalData

pre
var requestBody = {
"status": "sent",
"payload": {
"message": msgString,
"badge": 0,
"customData":{
"customName":"something or another"
}
},
"filter": {
"deviceID":deviceID
}
};
var request = {
"headers": {
"X-Appery-Push-API-Key": pushAPIKey,
"Content-Type": "application/json"
},
"body": JSON.stringify(requestBody)
};
var XHRResponse = XHR.send("POST", "https://api.appery.io/rest/push/msg", request);
/pre

On the device side, upon receiving Push Notification, try:
pre
alert(arguments[1].additionalData.customName);
/pre

Return to “Issues”