我能够使推送通知正常工作。我在REST上测试过它。
POST
Host: android.googleapis.com/gcm/send
Content-Type: application/json
Authorization: key=**apiKey**
Cache-Control: no-cache
Postman-Token: b33c61dc-a779-9198-bd96-aaf6c24fac6c
{
"data": {
"message": "hello world"
},
"registration_ids" : ["**deviceToken**"]
}
我的设备收到了通知。现在我正在努力使解析推动工作。
POST localhost:7002/server/push
X-Parse-Application-Id: SSShop
X-Parse-Master-Key: 123
Content-Type: application/json
{
"where": {},
"data": {
"alert": "hello world 123"
}
}
输出:{ result: true }
,但未在设备上收到通知。尝试通过Parse Dashboard发送推送通知并获得如下输出:
verbose: sending push to 2 installations
verbose: sent push! 0 success, 0 failures.
server.js:
const instance = {
appId: 'SSShop',
port: 7002,
serverURL: 'http://localhost:7002/server',
masterKey: '123',
databaseURI: 'mongodb://docker/ssshop',
publicServerURL: 'http://localhost:7002/server',
mountPath: '/server',
verifyUserEmails: true,
appName: 'SSShop',
emailAdapter: {
module: 'parse-server-simple-mailgun-adapter',
options: {
fromAddress: 'XX',
domain: 'XX',
apiKey: 'XX'
}
},
push: {
android: {
senderId: "92014XXXXX",
apiKey: "**apiKey**"
}
}
}
的package.json:
"parse": "~1.8.5",
"parse-dashboard": "~1.0.13",
"parse-server": "~2.2.11",
检查node_modules并使用parse-server-push-adapter使用版本1.0.4。