最近,我想将基于旧二进制API的推送通知代码更改为新的http2 API。问题是,当我连接到apple时,我应该为此http2 API使用不同的证书吗?因为当我使用http2 API向Apple发送带有有效令牌的通知(当我使用旧API发送通知时令牌有效),它会返回“BadDeviceToken”。所以我想知道令牌是非常糟糕还是我使用的证书不合格。
答案 0 :(得分:0)
We were also trying to break our heads with such an issue where we were trying to send push to production device tokens using the HTTP/2 API but were getting {"reason":"BadDeviceToken"} as the response and it was a clear mistake from our side, we were using the same code that we were using for test push notifications on dev environment to send push notifications on production, which was sending push to
https://api.development.push.apple.com/3/device/
rather for production it should be
https://api.push.apple.com/3/device
Hope it helps somebody but one issue with the new API is the distribution SSL certificate works for both the sandbox and production, not the other way round so be careful.
答案 1 :(得分:-1)
您仍然可以将旧证书与新的HTTP / 2 API一起使用。
BadDeviceToken
最常见的原因是您尝试使用开发令牌推送其生产网关,反之亦然。
令牌仅对开发或生产有效,这取决于您的应用程序的配置文件。