Consider a push model
Because polling as a mechanism is rather inefficient in itself, we should use server notifications and push delivery where possible. A natural choice for that would be WebSockets, HTTP/2 protocols, or long polling (also known as Comet) techniques with classic HTTP, as we discussed in Chapter 9, Optimizing Networking Performance.
However, server notifications can be optimized for mobile exactly in the same way we would optimize client-side transfers, namely by batching the notifications and sending them to the client only when its radio is in the active state. On the Android platform, Google's Firebase Cloud Messaging (FCM) solution offers, among other things, exactly that: it can aggregate notifications and send them ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access