Getting different device id of one device from gcm

117 views Asked by At

I am working on Push notification,i have registered my application in google console. when i fetch device id, it returns different device id everytime in onRegistration() of GCMIntentService class.Please Help me regarding this.

@Override protected void onRegistered(Context context, String registrationId)
 { 
   Log.i(TAG, "Device registered: regId = " + registrationId);     
   SavePreferences(registrationId,context);
   //Log.d("NAME", MainActivity.name); 
  //ServerUtilities.register(context, MainActivity.name, MainActivity.email, registrationId); 
}
1

There are 1 answers

2
JustWork On

It is a normal situation. You should NOT register device continuously. Register and save deviceId to somewhere (e.g. SharedPreferences) and the next time check if you have deviceId on SharedPreferences.

I think it's better for you to follow the article: https://developer.android.com/google/gcm/client.html

It has everything (almost) you need to.