user592419
user592419

Reputation: 5223

With the GMail API, what's the preferred way to get new messages?

The app I'm making needs to monitor the Inbox for new messages. As far as I am aware, there is no way yet for the GMail API to push a notif to me when a user has a new message (Push notification for new gmail).

I could check every minute for new messages by using the history IDs. Is that the current best method outside of implementing a full IMAP solution (which would no longer be utilizing the GMail API)?

Upvotes: 2

Views: 1324

Answers (1)

Jay Lee
Jay Lee

Reputation: 13528

The most efficient Gmail API method would be to use history.list(). Specify a labelId of Inbox (so you're not seeing updates on other labels) and a historyId of whatever the largest historyId you've previously seen is (you'll need to track this). If you get back a 404 error, you'll need to use messages.list() instead to perform a full sync.

Upvotes: 2

Related Questions