我的云代码看起来像这样。它发送到iOS很好,但是当发送到Android设备而不是消息时,它获得了大量有效负载的JS代码。:
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);
});
});
当它发送给Android用户时,他们会获得所有的Javascript代码,而不仅仅是消息的正文。如何解决这个问题?
答案 0 :(得分:0)
数据文字:
data: {
alert: {
title: "Prayers Lifted!",
body: whoPrayed + " just prayed for you.",
"loc-args": prayersObjectID,
},
category : "TAGGED_CATEGORY",
sound: "default.caf"
}
从我在文档中可以看到的内容看起来无效。 https://parse.com/docs/js/guide#push-notifications-customizing-your-notifications
如果您这样做会发生什么:
data: {
alert: "Some alert",
title: "Prayers Lifted!",
body: whoPrayed + " just prayed for you.",
loc-args: prayersObjectID,
category : "TAGGED_CATEGORY",
sound: "default.caf"
}