22

I need to save my users iOS and Android device token into a mySql DB so that I can send out push notifications.

My question now is what length is the device token for iOS and Android, is a column varchar(64) enough for a token?

user2722667
  • 8,195
  • 14
  • 52
  • 100
  • 1
    See [Size of iPhone device token](http://stackoverflow.com/q/12452448) and [android GCM registration ID max length](http://stackoverflow.com/q/11324666). – eggyal Mar 23 '15 at 16:47

4 Answers4

8

The Android device token is way longer than iOS device token.

I got 152 characters in the Android. While 64 total in iOS

Sree
  • 530
  • 1
  • 8
  • 20
Scar
  • 379
  • 4
  • 21
  • 1
    My token from today is 152 characters long.So they seem to change either over time, or evolve with new system. – Pierre Dec 28 '16 at 15:01
  • A google engineer [said the registration ID can grow up to 4K](https://groups.google.com/forum/#!msg/android-gcm/q2PzJTP71TY/DNX4lvDu5X4J) in Google Cloud Messaging. In practice, the tokens are going to be much smaller than that, but you shouldn't rely on this behavior going forward. – naXa stands with Ukraine Jun 02 '17 at 10:32
  • On `iOS` tested and it's 152. – Ionut Necula Aug 31 '17 at 12:12
4

As others have mentioned, I wouldn't rely on the length of the token to differentiate the two. Just a quick look in a large database showed me that there are iOS and Android devices that can have tokens of 152 or 174 characters.

You will want to rely on something else to differentiate them.

3

iOS Device Token length is 64 and android device token length will be 152.

Sree
  • 530
  • 1
  • 8
  • 20
Pavan Gandhi
  • 1,729
  • 1
  • 22
  • 36
2

It looks like it evolved to 174 for Android today. Most likely it will change in the future again