Event pages keep apps and extensions efficient by allowing them to respond to a variety of events such as timers or navigation to a particular site, without having to remain running persistently. But what if you need to respond to something that occurs outside of Chrome, such as a news alert, a message sent to a user or a stock hitting a price threshold? Until now, you had to do this by repeatedly polling a server. This process consumed bandwidth and reduced the battery life of your users' machines. For a more efficient solution, starting today you can use Google Cloud Messaging for Chrome (GCM) - across all channels of Chrome.
GCM will be familiar to developers who have used Google Cloud Messaging for Android. To send a message, all you need to do is:
- Request a token (channel ID) via chrome.pushMessaging.getChannelId().
- Pass the returned token to your server.
- Whenever you need to send a message to your app or extension, post the message along with the token to the GCM server-side API.
Your message is then delivered in near real time to Chrome. This makes your event page wake up (if it's not already running), and the message is delivered to your chrome.pushMessaging.onMessage listener.
Read more: Google developers blog
QR: