To send push from Parse cloud code I have code like this:
var channelList = ["IssuesAnswers"];
if (isNotificationNeed) {
var pushQuery = new Parse.Query(Parse.Installation);
pushQuery.equalTo('user_email', owner.get("username"));
Parse.Push.send({
channels: channelList,
where: pushQuery,
data: {
action: "com.mycompany.myapp.NEW_MESSAGE",
issue_id: issue.id,
issue_title_preset: issue.get("title"),
message_id: request.object.id,
}
},
{
success: function () {
console.log("Notification sent!");
// Push was successful
},
error: function (error) {
// Handle error
}
});
}
It doesn't work. No errors in log of console and no log in "Push" section. But if I comment line:
//channels: channelList,
It works. But my aim to send push to single installation IF user subscribed to chanel. How should I fix it?
You can't use both channels and where in your Push.send body.
You should write something like this :
var pushQuery = new Parse.Query(Parse.Installation);
pushQuery.equalTo('user_email', owner.get("username"));
pushQuery.containedIn('channels', channelList);
and remove channels from the Push.send body.