我正在尝试让推送通知工作,在解析服务器(Heroku)上,使用iOS应用程序。
此时,我可以通过运行以下命令在我的iOS应用程序中收到通知:
curl -X POST \
-H "X-Parse-Application-Id: 12345678ABCDEFstuvwxyz" \
-H "X-Parse-Master-Key: ABCDEF12345678stuvwxyz" \
-H "Content-Type: application/json" \
-d '{
"where": {
"deviceType": {
"$in": ["ios"]
}
},
"data": {
"aps": {
"alert": {},
"content-available": 1
},
"title": "The Shining",
"alert": {},
"content-available": 1
}
}'\ https://myapp.herokuapp.com/parse/push但现在我必须从云代码发送推送通知,也就是从Parse.Cloud.afterSave函数发送。
这就是我尝试过的,遵循我在网上找到的一些示例代码,但它不起作用:
Parse.Cloud.afterSave("Item_List", (request) => {
Parse.Push.send({
??????
data: {"alert": "NOTIFICATION-FOR-USERS"},
}, { success: function() {
console.log("#### PUSH OK");
}, error: function(error) {
console.log("#### PUSH ERROR" + error.message);
}, useMasterKey: true});
});获得我想要的东西的正确方法是什么?
发布于 2020-03-02 14:50:29
尝试如下所示:
Parse.Cloud.afterSave('Item_List', async () => {
const query = new Parse.Query(Parse.Installation);
query.equalTo('deviceType','ios');
await Parse.Push.send({
where: query,
data: { alert: 'NOTIFICATION-FOR-USERS' },
useMasterKey: true
});
});https://stackoverflow.com/questions/60473011
复制相似问题