Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best approach for renewing/recreating a Google push notification channel before expiration

I'm using a Google Calendar Push Notifications in my web app. Currently, I'm able to create a notification channel with a unique id and resource id. I'm also receiving a push notification whenever any event added/edited in the calendar.

What would be the best approach for renewing/recreating channel just before expiry time with users presence? In the Database, I'm saving user id , channel id, expiry time, current channel creation time.

like image 753
Saad Avatar asked Jan 05 '14 16:01

Saad


1 Answers

The Google Push Notifications API says that you can renew before the expiration; indeed, they implicitly recommend doing so:

"Currently there is no automatic way to renew a notification channel. When a channel is close to its expiration, you must create a new one by calling the watch method. As always, you must use a unique value for the id property of the new channel. Note that there is likely to be an "overlap" period of time when the two notification channels for the same resource are active."

Does PHP offer no timer mechanism? In Java, I'd note the expiration time and set a Timer or similar to renew the notification just before hand - no need to poll the DB repeatedly for an expiration date that's not going to change...

like image 97
dcsohl Avatar answered Oct 31 '22 23:10

dcsohl