0

We are researching different approaches to run a background task in Android and iOS. We have heard client-side tasks can be very battery intensive. Since our app involves polling an imap server, why not compare to a similar service.

We were wondering, which approach does Gmail/Outlook use? Does it poll and check email on the client device using a background task, then send a local notification? Or does it poll and check on its servers and send a remote notification via its GCM push notification service to the client?

wayofthefuture
  • 8,339
  • 7
  • 36
  • 53
  • 1
    I don't have sources for these, but on Android: Gmail App with Gmail uses GCM Push. For non-compatible services (generic IMAP servers), it uses Android Sync Adapters, which is scheduled by the system at configurable intervals when the network is up, etc. – Max Aug 15 '16 at 13:59
  • 1
    You should use a SyncAdapter, it takes power to turn on the radio in the phone everytime it needs to pull data. By using a SyncAdapter, your task will be scheduled with other tasks which Android is aware of. This allows the system to save battery. Also, you can read into "tickling" a server rather than "polling". – apelsoczi Aug 15 '16 at 14:20
  • @max So it is safe to assume that for all 3rd party imap email addresses, Outlook would be using client polling via the Sync Adapter as well? It would be hard to believe they have a server mega-structure devoted to checking everyones emails. – wayofthefuture Aug 15 '16 at 14:24
  • 1
    @wayofthefuture Correct. If you use 'adb logcat', you can probably see the sync adaptor running. – Max Aug 15 '16 at 15:20
  • @max I've kind of read that the SyncAdapter only allows syncing of server database with local database. If this is true, would that mean imap polling would not even be possible via SyncAdapter? Thanks – wayofthefuture Aug 16 '16 at 15:30
  • 1
    The intention is for you to sync your local state with the remote state. How you do that is up to you. The AOSP mail client certainly uses this model to synchronize a local messaging database with the server state. – Max Aug 16 '16 at 18:13
  • The Outlook app on my iPhone notifies me when new messages arrive, quickly. According to iOS Background Fetch mode, a specified time interval is not allowed and there is no guarantee it will even run (http://stackoverflow.com/questions/38993375/how-to-run-background-process-for-background-fetch-mode-in-ios-app). This would mean that Outlook is not using Fetch, which means the only other option left is remote push notifications. That would mean they are polling on the server and sending us remote push notifications, so would need a large centralized server infrastructure to handle the load? – wayofthefuture Aug 17 '16 at 14:00

0 Answers0