iOS background usage of Network.Framework

304 Views Asked by At

I've written a simple WiFi based App using TCP on Network.Framework that receives about 80 bytes every 10s from a remote service on specific port. I want to write this data to file while in the foreground and the background.

The question is which of the background modes if any/is permitted/best fits this requirement?

All wisdom gratefully accepted.

1

There are 1 best solutions below

3
On

Without knowing anything else about your app (is it a music app?, location?, VoIP?, bluetooth?) it's hard to say what you might do. But there are two classes of background actions:

  1. Actions that are ongoing when you go to the background that can be finished.
  2. Permitted background actions for specific kinds of apps. See "Implementing Long-Running Tasks" in the link you have about background modes.

The first doesn't really apply to you since this is ongoing. Of the second items, I'd guess that "Background fetch" is the one that fits best.

Note that you won't necessarily be called as regularly as you might like. But since your time interval is quite long (10sec) then a few hundred milliseconds latency wouldn't be particularly damaging I'd guess.

But also note that "Enabling this mode is not a guarantee that the system will give your app any time to perform background fetches. The system must balance your app’s need to fetch content with the needs of other apps and the system itself."