recommended way to detect new received mail?

2,214 views
Skip to first unread message

Michael Hosford

unread,
Aug 17, 2017, 9:54:04 PM8/17/17
to InboxSDK
Can anyone recommend "the best way" to detect new received mail in my InbokSDK Chrome extension?  I've been reading about the Gmail API's support for push notifications, and I can certainly go there if necessary, but I wanted to check with the community here in case there's some InboxSDK way of doing it that I'm missing...

Thanks--
Michael

Chris Cowan

unread,
Aug 18, 2017, 1:58:23 PM8/18/17
to InboxSDK
What would you plan on doing with a new email when it's received? If you wanted to do something with the email id, subject, or body as soon as it's received, then that's currently outside of the InboxSDK's scope because the InboxSDK mainly concerns itself with the UI visible to the user on the screen. We don't have functions for fetching the contents of emails that aren't on the screen. The Gmail API is a better fit if that's what you're interested in.

(It's arguable that we could add an event that fires whenever the unread email counter changes, but I'm not sure what real use that would ever get outside of triggering a request to a server that uses the Gmail API, in which case my suggestion would be to just use Gmail API webhooks instead. Also that way you don't miss messages while the user is offline.)

Michael Hosford

unread,
Aug 18, 2017, 4:43:30 PM8/18/17
to InboxSDK
Hi Chris, thanks for the fast response.  Yeah, I should have been more specific.  I do not need specifics of the received email(s); I just want to use the arrival of new email to trigger a process in the local extension that does indeed make calls to the Gmail API.  In my current version, this process gets called when the user opens the first Gmail tab/window, and periodically (every few minutes) thereafter while a signed-in Gmail tab remains open.  This is fine, except in the case where the user receives a new email and immediately composes a response before the "chron" process runs (this has the potential to happen a lot, I would imagine), because I want the received content (specifically, the contents of a custom email header in the received message) to be available to my extension to inform its behavior as the user composes the response.

I'm not concerned about missing messages while the user is offline-- we'll pick them up when they reconnect.  I might be a little concerned about open Gmail tabs on multiple devices (logged into the same account) performing redundant Gmail API calls... but I don't think the redundancy will be huge, and if it is, I have some ideas about how to fix that.

So, if there were an event that fires whenever the unread email counter changes, I would use it.  I realize that it may seem like I'm saying "I want you to do some work so I don't have to" -- but I think that a new email event may actually be the best/simplest way.  If there are enough InboxSDK users who would use it, would you consider adding it?  

Thanks--
Michael

P.S. (I also think there could be use cases that don't involve triggering calls to the Gmail API.)

Sanchit Bareja

unread,
Aug 19, 2017, 9:36:15 PM8/19/17
to InboxSDK
You could keep track of an array of unread emails and check for new unread emails as they come in. From there, you could trigger your API calls. This might not all happen in real-time though and possibly only when the user reloads the UI.

Michael Hosford

unread,
Aug 19, 2017, 11:13:07 PM8/19/17
to InboxSDK
Hi Sanchit -- in order to do that, I would need a way to detect the arrival of new incoming emails.

Anurag goyal

unread,
Mar 4, 2021, 4:44:53 AM3/4/21
to InboxSDK
hi Michael,
i want trigger event when a mail received , can you help me what is the best way to do it. Does i have to use google gmail api for this || or || inboxSDK will help me for this.
Reply all
Reply to author
Forward
0 new messages