我编写了一个简单的作业来尝试向自己发送推送通知。这是代码:
Parse.Cloud.job("testPush", function(request, status) {
Parse.Cloud.useMasterKey();
var installationQuery = new Parse.Query(Parse.Installation);
installationQuery.equalTo("user", "6t1JIuNqe1"); // I triple checked - this is the value of my user in the installation table.
Parse.Push.send({
where: installationQuery,
data: {
alert: "Test"
},
}, {
success: function() {
console.log("The Push Test Worked!");
status.success("All done with the push test!");
}, error: function(error) {
console.error("Something bad happened " + error);
status.error("Something bad happened during the Parse test...");
}
});
});
虽然它在 Parse 中记录作业已成功运行,但我从未在我的 iPhone 上看到通知。我检查了“设置”- 那里的所有设置都正确(通知可以出现并且应该显示为横幅,它们应该出现在通知中心,它们应该出现在我的锁定屏幕上)。然而通知从未出现。
我还需要检查什么?我错过了什么?
最佳答案
指针字段应与实例一起使用。
尝试将 installationQuery.equalTo("user", "6t1JIuNqe1");
替换为以下内容:
var user = new Parse.User();
user.id = '6t1JIuNqe1';
installationQuery.equalTo('user', user);
关于ios - 推送通知不是来自解析云代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27221267/