I am reading GCM tutorials and I need some explanations about InstanceID and RegistrationIntentService (gcm.play.android.samples.com.gcmquickstart)
In the javadoc I read, RegistrationIntentService of gcmsender app (android samples) , the Intent is launch at each application startup. The following code is then called :
InstanceID instanceID = InstanceID.getInstance(this);
String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
// Subscribe to topic channels
It is written "Initially this call goes out to the network to retrieve the token, subsequent calls are local." So I assume each time I request a token, only the first time a network call is made ? (first time I launch the application). If true : why this code is written without a if condition ? Why do I need to request it each time ? Why should I start this Intent at each application startup?
It is written that I have to store a boolean preference if the token has already been sent to my server. It is the reason I think it is necessary to call InstanceID and subscribeTopics at each app start but I don't understand why exactly.