Android Push Notifications - Registration And Unregister

 I have a few questions regarding Android notifications.

 

  1.  Does the Corona client request a registration ID on every start?  According to Google’s GCM docs the registration ID should be stored and only requested if it does not exist.  Also the registration ID might change on the GCM side from time to time.  How does Corona handle this case?

 

  1.  How does one go about un-registering a device from push notifications?

 

Thanks.

 

Nathan.

See this http://www.coronalabs.com/blog/2012/12/25/corona-holiday-gifts-android-push-and-more/

vovasoft,

 

I have read both the Push Notifications tutorials for iOs and Android.  They make no mention of the issues stated above.

 

Thanks any way.

Nathan.

I’m not expert but try to see in simulator Help -> Sample projects -> Notifications -> GooglePushNotifications

vovasoft,

 

I got that sample working.  What concerns me is that the sample app registers your device on every start.  According to Google’s docs you’re not suppose to do that.  The second question above deals with the situation where a user might want to un-register the device from receiving notifications.  I suspect that this happens automatically when the user uninstalls the app.

 

Nathan.

Boark,

Corona does not request for a registration ID from GCM multiple times.  Once a registration ID has been received, Corona caches it and uses that ID from then on.

If you change the project number in your “config.lua” file, then Corona will unregister the last registration ID it has received (if any), and then request a new registration ID with your new project number which will be cached once received.  This happens on app startup.

If you remove the project number from your “config.lua” file, then Corona will unregister the last registration ID it had cached (if any) on app startup and then clear the cached registration ID.

The above is pretty well tested, because we thought these would be common issues during testing/experimenting with Google push notifications.

Regarding Google expiring registration IDs, honestly, it isn’t clear to me how Google handles that.  I would imagine that Google would send an “unregister” intent to the application, which Corona would then automatically clear its cached registration ID, but I see nothing in Google documentation or sample code that allows us to recognize if the unregister notification was triggered by Corona unregistering itself or if it was initiated by Google.  So, Corona will not automatically re-register for a new ID afterwards… but that said, Corona would attempt to re-register on the next app startup since it will recognize that there is no cached registration ID.  Note that an app on Android will effectively restart when you press the Back button and then go back into the app.

Anyways, I hope this helps.

See this http://www.coronalabs.com/blog/2012/12/25/corona-holiday-gifts-android-push-and-more/

vovasoft,

 

I have read both the Push Notifications tutorials for iOs and Android.  They make no mention of the issues stated above.

 

Thanks any way.

Nathan.

I’m not expert but try to see in simulator Help -> Sample projects -> Notifications -> GooglePushNotifications

vovasoft,

 

I got that sample working.  What concerns me is that the sample app registers your device on every start.  According to Google’s docs you’re not suppose to do that.  The second question above deals with the situation where a user might want to un-register the device from receiving notifications.  I suspect that this happens automatically when the user uninstalls the app.

 

Nathan.

Boark,

Corona does not request for a registration ID from GCM multiple times.  Once a registration ID has been received, Corona caches it and uses that ID from then on.

If you change the project number in your “config.lua” file, then Corona will unregister the last registration ID it has received (if any), and then request a new registration ID with your new project number which will be cached once received.  This happens on app startup.

If you remove the project number from your “config.lua” file, then Corona will unregister the last registration ID it had cached (if any) on app startup and then clear the cached registration ID.

The above is pretty well tested, because we thought these would be common issues during testing/experimenting with Google push notifications.

Regarding Google expiring registration IDs, honestly, it isn’t clear to me how Google handles that.  I would imagine that Google would send an “unregister” intent to the application, which Corona would then automatically clear its cached registration ID, but I see nothing in Google documentation or sample code that allows us to recognize if the unregister notification was triggered by Corona unregistering itself or if it was initiated by Google.  So, Corona will not automatically re-register for a new ID afterwards… but that said, Corona would attempt to re-register on the next app startup since it will recognize that there is no cached registration ID.  Note that an app on Android will effectively restart when you press the Back button and then go back into the app.

Anyways, I hope this helps.