So most of you all know my love of shiny objects. With the release of 0.0.2 of the Admin
UI, i decided to make yesterday( friday. 8/2 ) a day about experimenting.
A while ago i started to play with Chrome Packaged Apps and sending Push messages to them
with GCM for Chrome[1] and how we could integrate that service into the Unified Push
Server. My first attempt back then failed, so i decided to have another go at it.
I'm happy to report that i got it working this time.
I created a chrome branch[2] in my fork of the Push server and also a chrome branch[3] in
my fork of the admin UI.
Just a quick rundown of how this messaging works:
1. you create an app in the google api console thing - same as android
2. Then you need to generate a refresh and access token - this is different than android
** the refresh token doesn't expire unless explicitly revoked, but the access token
does every 60 minutes(?)
3. Send the message with the client id, client secret( these 2 are generated from step 1 )
and the access token
it is not recommend to get a new access token for every request since there is a limit.
Integrating this into the push server wasn't to bad, just tedious because of all the
interfaces and such.
probably the crappiest code is the actual sender that i wrote( actually taken from the
simple push sender ). It gets a new access token every time which as i stated before is
bad.
I'm not sure if we should store the access token with the timer or what. The model
that i created for this has a clientId, clientSecret, and a refreshToken
here is the sample code that i threw together for receiving the notifications[4]. i
didn't make any comments or anything it them, just some things hacked together
I think GCM for chrome is somewhat new. It would be cool to add this for a 1.1 release or
something. i'm not really sure how much it is used, but the more networks we can
unify the better.
-Luke
1.
http://developer.chrome.com/apps/cloudMessaging.html
2.
https://github.com/lholmquist/aerogear-unified-push-server/tree/chrome
3.
https://github.com/lholmquist/aerogear-unified-push-server-admin-ui/tree/...
4.
https://github.com/lholmquist/chrome-app-codelab/tree/chromepush/lab2_basic