as i read, the gcm.register () function is deprecated. and I can use InstanceID.getToken () instead ...
I use it as described here,
but every time I run the application, I get a new RegID (instance id).
here as i registered:
@Override
protected String doInBackground(Object[] voids) {
String msg = "";
if (gcm == null) {
gcm = GoogleCloudMessaging.getInstance(MyApp.getContext());
}
InstanceID instanceID = InstanceID.getInstance(context1);
EntryActivity. regid = null;
try {
EntryActivity.regid = instanceID.getToken(ConstantsGCM.senderID_ProjectID, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
Log.d("REG---", "========================>>>- regid= " + EntryActivity.regid);
} catch (IOException e) {
e.printStackTrace();
}
if (EntryActivity.regid != null)
try {
storeRegistrationId(context1, EntryActivity.regid);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
Log.d("REG---", "- " + msg + "regid= " + EntryActivity.regid);
return msg;
}
and then I sent "regid" to my server and saved it to the database. So far, each of them worked fine, but when I send a message to the server via GCM (gcm.send (...);) and call the "from" field of the message (on the server side), I get a different regID, and each time when I restart the application and submit, I get a new regID (for each change regId has changed).
RegID, , , .