easygcm icon indicating copy to clipboard operation
easygcm copied to clipboard

No token renewal on OS update

Open adrien-aubel opened this issue 9 years ago • 6 comments

When Android is upgraded, Google offers no guarantee the GCM token will keep working, and we saw some cases where GCM would stop working after an upgrade to Android 5.1.

EasyGCM should probably listen to system boot and renew the GCM token if needed:

<uses-permission
    android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
...
<receiver android:name=".BootReceiver">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
</receiver>

Waiting a few seconds for the network to be available, or even better, some exponential backoff, could be a good idea.

adrien-aubel avatar Apr 27 '15 18:04 adrien-aubel

This would require adding a new permission (RECEIVE_BOOT_COMPLETED) - which I would like to avoid. I think we could do this as an optional feature of the library - you would specify the permission in your application manifest and the library would then handle it. I will have to think about this. Or maybe if someone can submit a pull request.

DanielNovak avatar Apr 29 '15 07:04 DanielNovak

@DanielNovak do you have any news about this?

If you want a PR, what would be some code design guidelines you'd have in mind?

adrien-aubel avatar May 21 '15 19:05 adrien-aubel

@adrien-aubel Sorry - no news yet, but I have it in my backlog. I haven't thought about it in detail yet - so now specific code guidelines :-(. I can't promise an ETA, but I would like to at least start this weekend on this.

DanielNovak avatar May 21 '15 20:05 DanielNovak

Ping @DanielNovak :)

adrien-aubel avatar Jun 01 '15 16:06 adrien-aubel

@adrien-aubel do not worry about code guidelines, regular Android style is fine. Just make a PR, that's where we can discuss :-)

martinadamek avatar Jun 02 '15 06:06 martinadamek

This could be fixed in version 1.5.0 as we started using com.google.android.gms.iid.InstanceID intent filter to renew the registration ID. This should be called also when device information is changed, which is probably also this case. More info here: https://developers.google.com/instance-id/guides/android-implementation

Probably needs testing, before we can close this issue

peterbartos avatar Jul 02 '15 09:07 peterbartos