oney / react-native-gcm-android

GCM for React Native Android
MIT License
172 stars 76 forks source link

Should onTokenRefresh() be included? #11

Closed ACCTFORGH closed 8 years ago

ACCTFORGH commented 8 years ago

As mentioned in the GCM doc, onTokenRefresh() should be invoked if registration token changed. Currently this method is not included in the package. Should this method be implemented? or the registration token stays same unless manually changed so this method is optional.

GCM doc link: https://developers.google.com/cloud-messaging/android/client?configured=true

Thanks.

oney commented 8 years ago

I will recommend doing requestPermissions every time when app starts, and check whether the token changes by yourself.

ACCTFORGH commented 8 years ago

Thanks! So the token won't change unless the app is terminated?

Also, one thing I am curious, I first put the requestPermissions() method after the addListeners method as in the instructions but did not get the "register" event captured and didn't see the received token printed in console. However, putting the method before the listeners works. Shouldn't the listeners be lasting and the sequence of requestPermissions() not affect the event being caught by the listeners?

oney commented 8 years ago

Hmm.. Token refreshing should be handled better. I will implement it in the future and welcome a PR!

I think the sequence of requestPermissions and listener matters. I can't figure out why putting requestPermissions() method after the addListeners doesn't work...

ACCTFORGH commented 8 years ago

Now, putting the method after the listeners works too. It could be just that it took some time for the app to first time register.