このページは大阪弁化フィルタによって翻訳生成されたんですわ。

翻訳前ページへ


chrome.pushMessaging - Google Chrome
The Wayback Machine - http://web.archive.org/web/20130824062934/http://developer.chrome.com/extensions/pushMessaging.html

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.

chrome.pushMessaging reference

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

interactive ( optional boolean )
callback ( function )

Callback

The callback parameter should specify a function that looks like this:

function(object channelId) {...};
channelId ( object )
channelId ( string )
The channel ID for this app to use for push messaging.

Events

onMessage

Fired when a push message has been received.

addListener

chrome.pushMessaging.onMessage.addListener(function callback)

Parameters

callback ( function )

Callback

The callback parameter should specify a function that looks like this:

function(object message) {...};
message ( object )
The details associated with the message.
subchannelId ( integer )
The subchannel the message was sent on; only values 0-3 are valid.
payload ( string )
The payload associated with the message, if any. This should not contain any personally identifiable information.