rdelrosario / xamarin-plugins

Cross platform Xamarin & Windows plugins for PCLs
MIT License
179 stars 161 forks source link

Refresh Subscription #28

Closed JohnMcAvinue closed 8 years ago

JohnMcAvinue commented 8 years ago

Hi,

I'm using Pushsharp to send GCM notifications and when I send to a particular registration Id the DeviceSubscriptionExpired callback is being fired.

This plugin doesn't seem to cater for this scenario as once there's a Token stored it continues to use that without checking if it's still valid.

Can you advise when I should be calling the unregister method?

rdelrosario commented 8 years ago

Will check this issue and will work on supporting this

On Wed, Jan 6, 2016 at 5:51 AM, John notifications@github.com wrote:

Hi,

I'm using Pushsharp to send GCM notifications and when I send to a particular registration Id the DeviceSubscriptionExpired callback is being fired.

This plugin doesn't seem to cater for this scenario as once there's a Token stored it continues to use that without checking if it's still valid.

Can you advise when I should be calling the unregister method?

— Reply to this email directly or view it on GitHub https://github.com/rdelrosario/xamarin-plugins/issues/28.

MKahmen commented 8 years ago

Hi @JohnMcAvinue ,

were you able to find a workaround?

Same issue occurs to me.

EDIT: https://github.com/rdelrosario/xamarin-plugins/issues/29

http://stackoverflow.com/questions/11590482/do-gcm-registration-ids-expire

When an application is updated, it should invalidate its existing registration ID, as it is not guaranteed to work with the new version. Because there is no lifecycle method called when the application is updated, the best way to achieve this validation is by storing the current application version when a registration ID is stored.

EDIT2: http://stackoverflow.com/questions/16838654/handling-registration-id-changes-in-google-cloud-messaging-on-android

The 'periodical' refresh never happened, and the registration refresh is not included in the new GCM library.

The only known cause for registration ID change is the old bug of apps getting unregistered automatically if they receive a message while getting upgraded. Until this bug is fixed apps still need to call register() after upgrade, and so far the registration ID may change in this case. Calling unregister() explicitly usually changes the registration ID too.

The suggestion/workaround is to generate your own random identifier, saved as a shared preference for example. On each app upgrade you can upload the identifier and the potentially new registration ID. This may also help tracking and debugging the upgrade and registration changes on server side.

rdelrosario commented 8 years ago

Just released a new version that sends registration each time register is called. Let me know if fixes the issue, if not reopen this issue.

MKahmen commented 8 years ago

just wanted to let you know, that it fixed the issue!

keep up the great work, man. thanks a lot! :-)

JohnMcAvinue commented 8 years ago

Thanks for doing this. I ended up hacking your code so it doesn't persist the token and registers all the time. It seems to work well. Thanks for all your hard work!