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:
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: