每当我使用以下云代码在Parse Server 2.2.24上发送推送通知
Parse.Push.send({
where: query,
data: {
alert: "You have a new comment on " + rift.get("title")
}
}, { useMasterKey: true }).then(() => {
console.log('Push ok');
}, (e) => {
console.log('Push error', e);
});
我在heroku上设置了verbose = 1,得到了以下日志。
2016-11-06T05:08:06.783331+00:00 app[web.1]: verbose: RESPONSE from [POST] /api/1/push: {
2016-11-06T05:08:06.783333+00:00 app[web.1]: "headers": {
2016-11-06T05:08:06.783334+00:00 app[web.1]: "X-Parse-Push-Status-Id": "NbZCxyCOgc"
2016-11-06T05:08:06.783334+00:00 app[web.1]: },
2016-11-06T05:08:06.783335+00:00 app[web.1]: "response": {
2016-11-06T05:08:06.783336+00:00 app[web.1]: "result": true
2016-11-06T05:08:06.783336+00:00 app[web.1]: }
2016-11-06T05:08:06.783337+00:00 app[web.1]: } X-Parse-Push-Status-Id=NbZCxyCOgc, result=true
2016-11-06T05:08:06.787076+00:00 app[web.1]: Push ok
2016-11-06T05:08:06.788233+00:00 app[web.1]: verbose: sending push to 1 installations
2016-11-06T05:08:06.789569+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Notification transmitted to 443d4d770217648350c5c7cd7bb22d2da77223e23c06f3eb016b2e2ca76d6202
2016-11-06T05:08:06.790600+00:00 app[web.1]: verbose: sent push! 1 success, 0 failures
2016-11-06T05:08:06.867209+00:00 app[web.1]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 443d4d770217648350c5c7cd7bb22d2da77223e23c06f3eb016b2e2ca76d6202
2016-11-06T05:08:06.868965+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Disconnected
2016-11-06T05:08:06.928135+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Connected
所以它说它被成功发送(我们没有收到通知到设备),我们得到一个ERR!解析服务器……对于在苹果TestFlight应用程序上分发的应用程序上从有效设备注册的每个设备令牌。我读了很多关于如何解决这个问题的帖子,并尝试了所有的方法,但没有任何效果。如果有人对为什么会发生这种情况有任何见解,请让我知道!我永远感激不尽
我们的index.js有如下配置设置:我们已经检查了生产证书,甚至拒绝了我们所有的证书,并生成了新的证书,只是为了确保。
push: {
ios: {
pfx: 'cert-prod.p12',
bundleId: 'a.bundle.id'
}
}
我最近有这个问题。您确定pfx文件的路径是一个完整的路径吗?我使用path模块来解决这个问题:
var path = require('path');
opts.push.ios = {
// The filename of private key and certificate in PFX
pfx: path.join(__dirname, env.IOS_PUSH_PFX),
bundleId: env.IOS_BUNDLE_ID
}
参考来源https://github.com/ParsePlatform/parse-server/issues/3025#issuecomment-258957541