Reputation: 482
I followed the GCM quickstart tutorial and its working fine, but i have a few questions that related to the behavior of the service itself
Once the GooglePlayServieces connection results as success:
Intent intent = new Intent(this, RegistrationIntentService.class);
startService(intent);
The Google documentation says that:
You should store a boolean that indicates whether the generated token has been sent to your server.
So, I stored it in my preferences so I know if my the token is in my server, but here are my questions.
onTokenRefresh()
I obviously need to send the token to my server again, so, is my duty to store the old token in my preferences to know which one to replace in my server or is stored in other place before it is refreshed?Upvotes: 0
Views: 690
Reputation: 1524
Is the service (not my server post implementation) called each time my app runs his MainActivity?
If it's in your onCreate() once per lifetime off app opened, if its onResume() every time the app comes in the foreground
If it does, how much impact have in the performance of network.
It's done on a seperate thread so it shouldn't be a problem, as it just sends a ping
Do i need another logic to manage if the service is called or not?
You would use some flag that you save in sharedPref to know if the service has been called before.
When onTokenRefresh() I obviously need to send the token to my server again, so, is my duty to store the old token in my preferences to know which one to replace in my server or is stored in other place before it is refreshed?
If you're refreshing a new token, i dont think you need to keep the outdated token, simply overwrite it with the new one you requested.
Upvotes: 2