Muhammad Aamir Ali
Muhammad Aamir Ali

Reputation: 21117

What is difference between android device id and device token?

I am getting android device id from this code of snippet which is for my device is "3b3472d8998af818"

protected String getDeviceId() {
    return Secure.getString(this.getContentResolver(), Secure.ANDROID_ID);
}

and android device token from this code of snippet which is for my device is
APA91bGeA3xOsXocz-eNOklONNVYwHyjvzyVMPQtC54_GX5Npx5fjWjpDbw6XOGqFi-a0lz7gL4BQlZXN-opPyHwJxxo3-1jyqjc1df6y8KwdVj7tUHVObcE3sF0XSpSngUkq6UfCEUTwgmsv-sjGuK863Y4R1kmHA

GCMRegistrar.register(this.context, CommonUtilities.SENDER_ID);

I don't know what is the difference between two ids?

Upvotes: 4

Views: 10262

Answers (1)

Pankaj Kumar
Pankaj Kumar

Reputation: 83028

Both are completely different.

Secure.ANDROID_ID

A 64-bit number (as a hex string) that is randomly generated on the device's first boot and should remain constant for the lifetime of the device. (The value may change if a factory reset is performed on the device.)

And GCMRegistrar.register(this.context, CommonUtilities.SENDER_ID); Gives you the registartion id of device from GCM. By which, GCM uniquely identifies the device.

Another difference is Secure.ANDROID_ID may change when factory reset is performed on the device. And Registration id gets changes periodically.

And if you are asking about CommonUtilities.SENDER_ID then This is your project number, and it will be used later on as the GCM sender ID

Upvotes: 3

Related Questions