0
votes

I'm running parse-server on ubuntu and can't seem to get push notifications working when sent in cloud code.

Push's work when using a REST api call (passing master key) but don't work when cloud code calls them.

What's interesting is that the cloud code Parse.Push() method returns a success and thus no error message.

My hypothesis is that this is a configuration problem, and the Parse.Push() method is referencing somethign I have incorrectly configured on the server.

here is my cloud function. This call works when sent via REST. and the success callback in cloud is always called.

Parse.Push.send(
  {
   // where: pushQueryClient,
    channels: ["user_tkP7gurGzc"],
    data:
    {
        alert: pushTextClient
    }
  },
  {
     success:function(){
        console.log("push sent");
        },
      error: function(error){
        console.log("push failed");
        console.dir(error);
       },

   useMasterKey: true});
1

1 Answers

0
votes

i think you have an issue with the useMasterKey parameter. Please try to use this code in order to send the push notification:

    Parse.Push.send({
      where: whereQuery,
      data: {
        alert: {
          title: request.params.title,
          body: request.params.body
        },
        type: request.params.type,
        sound: 'default'
      }
    }, {
      useMasterKey: true
    }).then(function() {
      response.success();
    }, function(error) {
      response.error("Push failed " + error);
    });

In this code i use Promises which is the best practice and also wrap useMasterKey in a separate object