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.
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.
OK, Sorted, found it in the code snippets
Hello Terry,
Glad to hear things are sorted out now!
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"
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:
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?