我正在尝试为Parse编写一个云代码作业,一旦大学达到50个用户,就会向某个大学的每个人发送推送。我非常确定我正确地编写了代码但是当我运行Job时,推送并没有被发送。有什么想法吗?
Parse.Cloud.useMasterKey();
Parse.Cloud.job("UniUsers", function(request, response) {
var query = new Parse.Query("Universities");
query.notEqualTo("pushSent", "Yes");
query.greaterThan("numUsers",49);
query.first({
success: function(uniObj){
var uni = uniObj.get("university");
var query2 = new Parse.Query("_User");
query2.equalTo("university", uni);
query2.limit(50);
query2.find({
success:function(results){
for (var i = 0; i < results.length; i++) {
var object2 = results[i];
var userid = object2.id;
var thePush = new Parse.Query("_Installation");
thePush.equalTo('user',userid);
Parse.Push.send({
where: thePush,
data:{
aps:{
alert: "Your University Has Been Unlocked!
Start searching for your Roomie now!",
sound: ""
}
}
});
}
response.success("Success!");
},
error:function(error){
response.error("Error");
}
})
}
})
});