Sample that shows how to use the Push Messaging API in an app.
How to install on your local machine:
- Download the Google App Engine SDK for Python.
- Ensure that
dev_appserver.py
is in your PATH - Go to the Developer Console, and request a "Client ID for Web Applications" using the "API Access" nav bar item, click on "Create an OAuth2 client ID".
- Use the "Web Application" type in the Create Client ID dialog.
- Use "localhost" for the URL.
- Click on "Edit settings" to edit the redirect URIs.
- Add
http://localhost:8080/oauth2callback
to the list of Redirect URIs for your Client ID (yes, http, not https for the sample.) - Download JSON for your client ID, and save it in the path
$PROJECT_ROOT/guestbook-srv/client_secrets.json
. - Click on the "Services" item on the left nav bar.
- Scroll down to "Google Cloud Messaging for Chrome", and turn it on.
~ cd $PROJECT_ROOT/guestbook-srv
~ dev_appserver.py .
- Upload the app in
$PROJECT_ROOT/guestbook-app
to the Chrome Web Store.
** When you go to the Chrome Web Store, Click the "gear" icon, and choose "Developer Dashboard". ** click "Add new item" - Download he app back to your browser.
- Don't launch the client app yet! Wait until the server is running, and you have navigated to localhost:8080/startpush and authorized your appserver to send messages. The client registers with the server on startup. If you do end up starting the client app too early, you can try first killling it from the chrome://extensions page, and if that doesn't work, you can restart the dev_appserver with the --clear_datastore argument.
- Navigate to
http://localhost:8080/startpush
and login with the account with push. You should only have to do this once, not every time. - Launch the push messaging sample app. It should have a message like "The last Guestbook message was "..."
- Send push messages
http://localhost:8080
by signing the guestbook web page. After you leave a message and press sign, the server will send the push message. - You should now see the payload of the push message appear in the push guestbook app.