我尝试在用户的状态更新发生更改后发送推送通知(状态更新在解析核心数据的提交类中进行管理)但我使用云代码来匹配用户的电话号码在用户和提交类中,以便推送通知仅针对一个特定用户。
Parse.Cloud.afterSave("submission", function(request) {
var statusText = request.object.get('status');
var phoneNumber = request.object.get('Phone');
Parse.Cloud.afterSave("User", function(request) {
var userPhone = request.object.get('Phone');
var pushQuery = new Parse.Query(Parse.submission);
pushQuery.matchesQuery(userPhone, phoneNumber);
Parse.Push.send({
where: pushQuery, // Set our Installation query
data: {
alert: "Status Change: " + statusText
}
}, {
success: function() {
},
error: function(error) {
throw "Got an error " + error.code + " : " + error.message;
}
});
});