title: GCM token refresh and when to send the token to server
body: <p>I am following a <a href="https://github.com/googlesamples/google-services/blob/master/android/gcm/app/src/main/java/gcm/play/android/samples/com/gcmquickstart/RegistrationIntentService.java#L99-L104" rel="nofollow">GCM-Android</a> integration example from the official guide. </p>
  
  <p>In particular I am confused about the following lines in the above linked class: </p>
  
  <pre><code>// You should store a boolean that indicates whether the generated token has been
  // sent to your server. If the boolean is false, send the token to your server,
  // otherwise your server should have already received the token.
  </code></pre>
  
  <p>Now I call the intent service each time my main activity launches and I believe that instanceID is responsible for initiating the token refresh. </p>
  
  <p>Should I check the Shared Prefs value each time I initiate this GCM registration intent from my Main Activity. However refresh will fail in this case because after initial token fetch the condition will always be true. </p>
  
  <p>Should I discard the shared prefs logic  - this way a fresh token will be sent to my server each time. What is the proper way of doing this? How does the token refresh worrk and when does it refresh? </p>