这就是我使用 Parse JS Cloud Code 向“highPush”用户子集发送推送通知的方式:
Parse.Cloud.job("sendHighPush", function(request, status) {
Parse.Cloud.useMasterKey();
Parse.Push.send({
channels: ["highPush"],
data: {
alert: "New match found!",
badge: "Increment"
}
},
{
success: function() {
// Push was successful
console.log('Push Notifications completed successfully.');
},
error: function(error) {
throw "Got an error " + error.code + " : " + error.message;
}
}).then(function() {
// Set the job's success status
status.success("Push Notifications completed successfully.");
}, function(error) {
// Set the job's error status
status.error("Uh oh, ain't no pushing going on here.");
});
});
我想要做的不仅仅是将此推送通知发送给所有“highPush”用户,而是让推送通知字符串分别包含特定于每个用户的信息。因此,我希望警报不是说“找到新匹配!”,而是说“找到 iPhone 5S 16gb 的新匹配!”,其中“iPhone 5S 16gb”是与该特定用户关联的对象的字符串属性。
从 Parse 文档中可以看到,我只能找到向一部分用户发送标准推送通知的方法,但无法单独向每个用户自定义推送通知内容。有什么办法可以做到这一点吗?
最佳答案
不幸的是,不能..推送数据/警报无法针对推送查询中的每个目标进行自定义。
此时,您需要向这些用户发送单独的推送通知并包含特定信息。
关于javascript - 如何在 Parse 推送通知中包含特定于用户的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29582459/