Gmail API Adds Push Notification Support

Developers using the Gmail API can now take advantage of push notifications to have their applications alerted when changes occur in a Gmail mailbox.

Announced last Friday at the Google I/O conference, the new feature is designed to make it easier for developers using Google's Gmail REST API to build applications that interact and sync with one of the world's most popular Web-based email services.

As detailed on the Google Apps Developer Blog, to use push notifications, developers first subscribe their applications to the Gmail mailboxes of interest and then use either Webhooks or Google's Cloud Pub/Sub service to receive change notifications.

Each Gmail mailbox being watched for changes is subject to a notification rate of one event per second; notifications above that rate are dropped. While Google says that notifications "should be delivered reliably within a few seconds, ... in some extreme situations notifications may be delayed or dropped." As such, Google recommends that developers implement their applications so that Polling takes place if notifications are not received after a certain period of time.

The End of Polling? Not Exactly

Webhooks and services like Cloud Pub/Sub are increasingly popular, and more and more API providers are employing them to offer developers the ability to have data pushed to their applications, eliminating polling.

This has benefits for both parties. For developers, less polling means less Resource utilization, and in some cases less application complexity. For API providers, less polling also means less resource utilization, which can be especially costly for popular APIs serving large volumes of concurrent requests.

But despite the growing popularity and availability of push notifications using Webhooks and pub/sub services, push notifications aren't without their potential disadvantages. Developers must assume that API providers deliver notifications reliably, and in critical applications, may still need to implement polling as a fallback. And for API providers, managing notification subscriptions reliably and efficiently adds more complexity.

For these reasons and others, there remain some use cases that warrant polling. For instance, Google suggests that polling is still the recommended approach for generating notifications to user-owned devices such as native apps and browsers.

Be sure to read the next Email article: Daily API RoundUp: Auth0, Dota2, Sift, Quini, Blockchain, Marvel Comics Android Library