Skip to content

Instantly share code, notes, and snippets.

@t-kashima
Created May 29, 2013 16:18
Show Gist options
  • Save t-kashima/5671568 to your computer and use it in GitHub Desktop.
Save t-kashima/5671568 to your computer and use it in GitHub Desktop.
Google Cloud Messaging for Chrome Demo - http://www.atmarkit.co.jp/ait/articles/1305/24/news014.html
console.log 'backgroud.js is working!!!!!!'
chrome.pushMessaging.onMessage.addListener (message) ->
alert 'GCM message: ' + message.payload
script type="text/javascript" src="background.js"
{
"name": "GCM Demo",
"version": "1.0.2",
"manifest_version": 2,
"description": "GCM for Chrome Extension Demo",
"browser_action": {
"default_title": "GCM Demo",
"default_popup": "popup.html"
},
"background": {
"page": "background.html"
},
"permissions": ["background", "pushMessaging"]
}
elementTextChannelId = document.querySelector '#textChannelId'
console.log 'Hello, Chrome Extension'
chrome.pushMessaging.getChannelId false, (response) ->
elementTextChannelId.value = response.channelId
doctype 5
html
head
meta charset="UTF-8"
title GCM for Chrome
body
h1 Hello, GCM for Chrome
div channelId:
input type="text" size="120" id="textChannelId"
script type="text/javascript" src="popup.js"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment