42

How do device tokens vary from sandbox to production modes?

I think I have locked up some device tokens into a production mode, and they can't be pushed to from development.

Any ideas on how I can check?

Kara
  • 6,115
  • 16
  • 50
  • 57
Art C
  • 842
  • 2
  • 10
  • 21
  • Not sure this helps, but if you try to send a production device token via sandbox (development mode) or vice-versa, you'll get an error saying the token is bad. Switch to the correct mode and it will work. – Jacksonkr Mar 22 '17 at 21:27

2 Answers2

126

When you build your app using a development cert, the app will generate a unique device token. This device token will not work on the production push network. When you then build your app with a distribution provisioning profile (App Store or Ad-Hoc) your device will generate a different device token for push notifications. If you try to send the development generated token to the production push SSL network, Apple's servers will reject your token.

marcc
  • 12,295
  • 7
  • 49
  • 59
  • 4
    Thanks. You saved my sanity with this answer. – n8gray May 02 '10 at 07:16
  • 4
    Why my development device token and production device token are the same? – lu yuan Jan 04 '13 at 10:18
  • 40
    Thanks. Is there a way to determine if a token was generated for the sandbox or development environment? – Jason Aug 31 '13 at 23:25
  • @Jasonit seems there is still no way to verify. If you use the wrong token on the wrong network, Apple will reject your token saying it is invalid. There is also a feedback service, but it can be unreliable (token not active marked as invalid) – Marco Pappalardo Apr 12 '17 at 13:25
  • @Jason did you found a way to figure out if the token is from sandbox or production? – johnny Jan 25 '20 at 02:29
4

What I did was to try production first, then if that failed with an InvalidToken code, then try it again against sandbox.

In case you're wondering, yes, this is harder than it needs to be.

Eliot Gillum
  • 832
  • 9
  • 18