这就是我使用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文档中看到的内容,我只能找到将标准推送通知发送给一部分用户的方法,而没有办法为每个用户分别自定义推送通知的内容。有什么办法吗?
不幸的是,没有。不能为推送查询中的每个目标自定义推送数据/警报。
此时,您将需要向这些用户发送单独的推送通知,并包括特定信息。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句