实际上,我们已经完成了从移动设备向移动设备发送推送通知以及使用解析查询向移动设备解析的过程。现在我们正在尝试使用 Javascript 将推送通知从 Web 应用程序发送到移动设备。
function authentication() {
Parse.$ = jQuery;
// Initialize Parse with your Parse application javascript keys
Parse.initialize("app key",
"javascript key");
Parse.Push.send({
//where: pushQuery,
channels: [ "Demo","Done" ],
data: {
alert : "Hello word"
}}, { success: function() {
// Push was successful
alert : "Push was successful"
// debugger;
},
error: function(error) {
}}).then (function(error) {
//Marks this promise as fulfilled,
//firing any callbacks waiting on it.
});
}
请指导我们,我们是 javascript 的新手。 我们收到这样的错误
POST https://api.parse.com/1/push 400 (Bad Request)
最佳答案
您是否在 Parse 应用的推送通知设置中激活了启用客户端推送?
However, if you decide to send notifications from the JavaScript SDK outside of Cloud Code or any of the other client SDKs, you will need to set Client Push Enabled in the Push Notifications settings of your Parse app.
发件人:https://parse.com/docs/js/guide#push-notifications-sending-pushes
请注意,您不应从任何客户端发送通知,而应从云代码触发通知
However, be sure you understand that enabling Client Push can lead to a security vulnerability in your app, as outlined on our blog. We recommend that you enable Client Push for testing purposes only, and move your push notification logic into Cloud Code when your app is ready to go into production.
关于javascript - 在 Parse 中使用 javaScript 发送推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30069183/