I'm using Google Cloud Messaging api to implement an Android client. To get a token, I do:
InstanceID ex = InstanceID.getInstance(this.getApplicationContext());
String regId = ex.getToken(senderId, "GCM", null);
And regId always contains a token, despite of I put on senderId. If I set senderId with "123", InstanceID returns a token! (But the, I don't receive notifications with this token). Why I always get a token? I expect an exception, or a null value maybe...
You may always get a token but you will not be able to use it to establish the full gcm lifecycle since
instanceId
is tied to your app server'ssenderId
.From the google documentation
To understand more of the lifecycle, refer to the documentation