简体   繁体   中英

Parse Cloud Code Push to Android Not Working

My cloud code looks like this. It sends just fine to iOS, but when sent to an Android device, instead of a message, it gets a whole lot of JS code for the payload.:

Parse.Cloud.define("userPraying", function(request, response) {
    var prayersObjectID = request.params.prayersObjectID;
    var whoPrayed = request.params.theirName;
      var recipientUserId = request.params.recipientId;
    var newRecipientUserId = recipientUserId.replace('User_', '');


  var pushQuery = new Parse.Query(Parse.Installation);
  pushQuery.equalTo("usersObjectId", newRecipientUserId);

    Parse.Push.send({
    where: pushQuery,
    data: {
      alert: {
      title: "Prayers Lifted!",
     body: whoPrayed + " just prayed for you.",
     "loc-args": prayersObjectID,
      },



      category : "TAGGED_CATEGORY",
 sound: "default.caf"
    }
  }).then(function() {
      response.success("Push was sent successfully.")
  }, function(error) {
      response.error("Push failed to send with error: " + error.message);
  });

});

When it is sent to an Android user, they get all of the Javascript code, instead of just the body of the message. How can this be fixed?

The data literal:

data: {
  alert: {
  title: "Prayers Lifted!",
  body: whoPrayed + " just prayed for you.",
  "loc-args": prayersObjectID,
  },



  category : "TAGGED_CATEGORY",
  sound: "default.caf"
}

Looks invalid from what I can tell in the documentation. https://parse.com/docs/js/guide#push-notifications-customizing-your-notifications

What happens if you do:

data: {
  alert: "Some alert",
  title: "Prayers Lifted!",
  body: whoPrayed + " just prayed for you.",
  loc-args: prayersObjectID,
  category : "TAGGED_CATEGORY",
  sound: "default.caf"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM