I have an application with login / logout that uses Android accounts. I also use GCM, so when the user logs in, I register the device, and if the user logs out, I cancel it. I ran into a problem with an unregistered call.
To unregister my device from my server, I need an account token. Since I cannot pass it to the onUnregistered method from GCMIntentService (or at least I donβt know how to do this), I tried to get it using the AccountManager, but at this point my account has already been deleted. I want to solve this, and it occurred to me two options:
1- Call GCMRegistrar.unregister first and delete the account in the GCMIntentService-> onUnregistered function. The problem with this solution is that the user has to wait for the registration to complete, and maybe not. I cannot allow the user to continue working without deleting the account.
2- Save the token somewhere (maybe the application class) to get it from GCMIntentService-> onUnregistered.
I think number 2 is better, but I don't know if it is the best. Is there a better way to solve it?
source share