Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

create a targeted push notification in server code using channels

I can't locate any info for creating targeted push notifications using channels. I want to do this in server code, so that I can call it as a service from an external website.

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

create a targeted push notification in server code using channels

OK, Sorted, found it in the code snippets

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

create a targeted push notification in server code using channels

Hello Terry,

Glad to hear things are sorted out now!

Terry Gilliver
Posts: 0
Joined: Fri Apr 18, 2014 8:45 pm

create a targeted push notification in server code using channels

Just run into an issue: Here is the code:

code// Push Notifications API key from:
// Apps > [App] > Push Notifications > Settings
// 'badge' is iOS only setting

var pushApiKey = "0813456a-4b56-4386-97a1-b3daacf5c3ee&quot
var message = request.get("message");
var channel = request.get("channel");
console.log("message = ",message);
console.log("channel = ",channel);
Apperyio.PN.send(pushApiKey, {
payload: {
"message": message
},
filter: {
"channels": {
"$in": [channel]
}
}
});/code

If I test this, the message is not sent, but there are no errors. The problem is somewhere in the syntax for the channels filter, if I remove the filter, then the message is sent. The Channel is set to 2 in the database for all devices. See the screenshot below:
Image

also i have found how to send a success response using Apperyio.reponse.success, but can you check the response status, and is there an Apperyio.reponse.error function?

Return to “Issues”