Wednesday, April 02, 2014
Last year we released Google Cloud Messaging (GCM) for Chrome that enabled Chrome Apps and extensions to receive push messages from their server-side components. While it provided developers with powerful new capabilities, it was not compatible with Google Cloud Messaging for Android, which led to inconsistencies in the feature sets supported for both platforms. Today we are releasing a developer preview of the new chrome.gcm API. The API shares server-side infrastructure with GCM for Android, which means cloud messaging has to be implemented only once on the server side for both Android and Chrome Apps.
The chrome.gcm API brings new capabilities and improvements over the existing chrome.pushMessaging API. A major new capability is sending upstream messages from the app to the server while still enjoying the benefits of the cloud messaging infrastructure, such as reliable message queueing or sending the messages only when a network connection is available. The API enhances messages by making them more structured, larger (up to 4KB), and allowing them to expire when not delivered within a specified time-to-live. Unlike the chrome.pushMessaging API, chrome.gcm API does not impose quota restrictions.
The API is available now on Chrome Canary and the Dev Channel. You can learn more about writing GCM-enabled Chrome Apps from our documentation. For a quick start, you can check out the GCM sample available on GitHub.
Providing Chrome developers with access to a cloud messaging infrastructure shared between Android and Chrome is an important step to simplifying development of apps and services spanning both platforms. Although the new GCM API is currently in developer preview, over time it will become the default way for developers to enable messaging for their applications. Please give it a try, and send us your feedback at Stack Overflow, our G+ Developers page, or our developer forum.
Posted by Filip Gorski and Jian Li, Software Engineers and Server Simplifiers