How to identify if device token is for android or iOS?
Asked Answered
G

5

7

I store Android and iOS device tokens in DB. Following are few examples of device tokens getting saved in the DB.

  • 359092050465370
  • 654C4DB3-3F68-4969-8ED2-80EA16B46EB0
  • 294913EC-6100-42E8-8C2D-E9F68F286ADE

How to differentiate whether a particular device token is for an Android or iOS device?

Gawen answered 26/11, 2013 at 9:23 Comment(6)
15 degit means android 32 degit means iosObediah
15-digit IMEI should be AndroidBriannabrianne
I think this 294913EC-6100-42E8-8C2D-E9F68F286ADE for iphoneGawen
@Gawen Has any answer been useful for you? Did you solve your problem?Phenomenon
@Gawen what is your preferred answer?Phenomenon
i believe sending additional details is better approach rather than digit diiferenceSharpie
P
7

I recommend that you send additional information along with the token to the server. For example, information about what type of device the token was registered from, i.e. Android or iOS. A suitable solution is the setup a REST service for registering your tokens. If you implement this solution, you are future proof with regards to future changes in Android/iOS token length. Other useful information to store is the user id or similar.

I assume that you do are talking about your own DB where you store the tokens.

Phenomenon answered 26/11, 2013 at 10:0 Comment(0)
E
2

Iphone Device token

The device token is 32 bytes binary form, means 32 degits for iphone and 15 for android

Electret answered 26/11, 2013 at 9:28 Comment(1)
Links to official docs stating this magic number would be great!Impetuosity
D
1

Your first hash you posted, is the IMEI of the device so it's present on both Android and iOs. An IMEI only contains numbers!

On Android, if you use the following code will give you an unique ID: Secure.getString(getApplicationContext().getContentResolver(), Secure.ANDROID_ID); that will look like that: 9774d56d682e549c which is 16 chars long.

On iOS devices, you can get your UDID on iTunes or on websites like this one: http://whatsmyudid.com/ This UDID is 32 digits and looks like that: 294913EC-6100-42E8-8C2D-E9F68F286ADE.

Basing on the IMEI you posted in your message, we can get your phone information such as Brand, Model and many other things. Take a look at that address: http://www.imei.info/?imei=359092050465370

Dulsea answered 26/11, 2013 at 9:34 Comment(1)
It is not allowed to use the UDID from an iOS device. The application will not be approved by Apple. Also the original question talks about device tokens. This is not to be confused with UDID.Phenomenon
F
-1

You need to implement GCM to do so.

Please follow this link for details explanations.

Google Cloud Messaging

       String rid=GCMRegistrar.getRegistrationId(getApplicationContext());
Fivefinger answered 26/11, 2013 at 9:54 Comment(1)
Does not answer the original question.Phenomenon
S
-2

To get IMEI (international mobile equipment identifier) :

public String getIMEI(Activity activity) {
    TelephonyManager telephonyManager = (TelephonyManager) activity
            .getSystemService(Context.TELEPHONY_SERVICE);
    return telephonyManager.getDeviceId();
}

To get device unique id :

public String getDeviceUniqueID(Activity activity){
    String device_unique_id = Secure.getString(this.getContentResolver(),
            Secure.ANDROID_ID);
    return device_unique_id;
}
Scabby answered 24/9, 2014 at 4:18 Comment(1)
This does not answer the question. The question has nothing to do with unique identifiers. It has to do with identifying the difference between Android & iOS tokens.Phenomenon

© 2022 - 2024 — McMap. All rights reserved.