chrome.pushMessaging
Description: |
Use chrome.pushMessaging to enable apps and extensions to
receive message data sent through
Google Cloud Messaging.
|
Availability: |
Stable since Chrome 24.
|
Permissions: |
"pushMessaging"
|
Learn More: |
Google Cloud Messaging for Chrome
API Reference for GCM service |
Debugging
Internal Server Error
The Push Messaging server responds with HTTP status code 500
(internal server error) if the app that calls the pushMessaging API
is not found in the Chrome Web Store. This ownership check
is designed to prevent people from sending messages to your app
without your permission. Commonly this error occurs during
development if you run a version of your app without the correct
key
attribute in its manifest file.
To fix this problem, simply install your app from
the Chrome Web Store and copy the key
field from manifest.json in the installed app to manifest.json in
the version of the app that you are developing
(see Testing in the cloud for
detailed instructions). Note that you need to remove the key
field from manifest.json before you upload the app to the Chrome Web Store again.
Summary
Methods | |
---|---|
getChannelId −
chrome.pushMessaging.getChannelId(boolean interactive, function callback)
| |
Events | |
onMessage |
Methods
getChannelId
chrome.pushMessaging.getChannelId(boolean interactive, function callback)
Retrieves the channel ID associated with this app or extension. Typically an app or extension will want to send this value to its application server so the server can use it to trigger push messages back to the app or extension. If the interactive flag is set, we will ask the user to log in when they are not already logged in.
Parameters | ||||||||
---|---|---|---|---|---|---|---|---|
boolean | (optional) interactive | |||||||
function | callback |
The callback parameter should be a function that looks like this: function(object channelId) {...};
|
Events
onMessage
Fired when a push message has been received.
addListener
chrome.pushMessaging.onMessage.addListener(function callback)
Parameters | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
function | callback |
The callback parameter should be a function that looks like this: function(object message) {...};
|