Reputation: 41
Recently, I want to change my codes of pushing notifications to apple from basing on old binary API to new http2 API. The question is that should I use a different certificate for this http2 API when I connect to apple ? Because when I send a notification to apple with a valid token(the token is valid when I send notifications with old API) using http2 API, it returns "BadDeviceToken". So I'm wondering whether the token is really bad or the certificate that I use is not qualified .
Upvotes: 3
Views: 1263
Reputation: 11276
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.
Upvotes: 2
Reputation: 3903
You can still use your old certificate with the new HTTP/2 API.
The BadDeviceToken
is most commonly because you are trying to push through their production gateway wth a development token or vice versa.
Tokens are only valid for either development or production, and this is determined by the provisioning profile of your app.
Upvotes: 1