February 2019
Intermediate to advanced
450 pages
11h 59m
English
Although Google provides the ability to use push messaging, the setup is very complicated—so instead, we'll poll for new messages. Every 10 seconds, we should download any new messages that have arrived. To do this, we can use the history API, which returns any messages that appeared after a specific point in history (set using StartHistoryId()). HistoryId is a chronological number that marks the order that messages arrived in. Before we can use the history API, we need to have a valid HistoryId—we can do this by adding the following line to the downloadMessage() function:
g.history = uint64(math.Max(float64(g.history), float64(mail.HistoryId)))
Once we have a point in history to query from, we need a new function ...
Read now
Unlock full access