更新:
npm install parse-server@2.4.2 --save
解决了这个问题,现在我有兴趣让它在2.6.5上运行
我已经有了解析服务器的工作配置,推送消息还可以。 我现在有2.6.5版本。
我有这个云代码功能来测试:
Parse.Cloud.define('testPush', function (req, res) {
// Find user
var userQuery = new Parse.Query(Parse.User);
userQuery.equalTo("objectId", req.params.userId);
// Find devices associated with this user
var pushQuery = new Parse.Query(Parse.Installation);
pushQuery.matchesKeyInQuery('deviceToken', 'deviceToken', userQuery);
//pushQuery.matchesQuery('user', userQuery);
// Send push notification to query
Parse.Push.send({
where: pushQuery,
data: req.params.data
}, {
useMasterKey: true,
success: function () {
res.success('push sent')
},
error: function (error) {
res.error('push not sent')
}
});});
我正在做这样的请求:
http --json POST 'http://example.com:1337/parse/functions/testPush' \
'Content-Type':'application/json' \
'X-Parse-Master-Key':'KEY' \
'X-Parse-Application-Id':'APPID' \
data:="{
"alert": {
"title": "Test Push",
"body": "Test Body"
},
"code": "3"
}"
userId="7128712387" \
text="Lorem ipsnum"
我的日志中没有任何错误,我只是:
0|parse-wr | verbose: RESPONSE from [POST] /parse/functions/testPush: {
0|parse-wr | "response": {
0|parse-wr | "result": "push sent"
0|parse-wr | }
0|parse-wr | } result=push sent
0|parse-wr | verbose: _PushStatus bYSCE3SnvX: sending push to 1 installations
0|parse-wr | verbose: Sending push to 1
0|parse-wr | verbose: _PushStatus bYSCE3SnvX: sent push! 0 success, 1 failures
0|parse-wr | verbose: _PushStatus bYSCE3SnvX: needs cleanup devicesToRemove=[]