Search code examples
javascriptparse-platformparse-cloud-code

Sending push using parse.com Cloud Code


I have a problem with sending a push notification from Cloud Code. I want to send Push after saving an AlertPoint object. My code looks like this:

Parse.Cloud.afterSave("AlertPoint", function(request) {
    Parse.Push.send({
        data: {
            alert: "Test push."
        }
    }, {
        success: function() {
            //push successsful
            }, 
        error: function(error) {
            //Handle error
            throw "Got an error" + error.code + " : " + error.message;
        }
    });
});

But the push is not sent and I get an error:

Result: Uncaught Got an error115 : Missing the push channels.

I would like to send the push to all registered users and I've seen code examples in which the push was sent without setting channels. What am I doing wrong and how to fix this error?


Solution

  • You have to subscribe all users in a blank channel and set the push to broadcast the message to this blank channel too.