Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get notified by Gmail when a new message arrives in Node.js app

I get all my 'UNREAD' messages with listMessages(), change label with modifyMessage() and publish them on Redis channel via publish() method.
But I asking for new message every minute.

How can I get notified by google when a new message arrives so I don’t have to poll every minute? I check "Push Notifications" in google doc, but can`t figure how should I done.
Could somebody explain me with simple words??

Thanks!

like image 920
Ms. Chanandler Bong Avatar asked Dec 15 '16 13:12

Ms. Chanandler Bong


1 Answers

The Push notification in Gmail API let you watch for changes to Gmail mailboxes. You can use this feature to improve the performance of your application. It allows you to eliminate the extra network and compute costs involved with polling resources to determine if they have changed. Also, it will lessen your quota usage.

But take Note that for notifications to user-owned devices (i.e. installed apps, mobile devices, or browsers), the poll-based sync guide is still the recommended approach to retrieve updates.

This documentation will help you on how to implement and work with the push notification, including how to receive it and respond with it.

like image 58
KENdi Avatar answered Oct 19 '22 11:10

KENdi