The BackgroundTasks framework is potentially useful for this sort of thing. In the traditional background fetch model, you were resumed in the background but only got a small execution time allowance. That meant you had to use a
URLSession
background session for your networking. With the BackgroundTasks framework you can receive large amount of background execution time, which gives you the choice of using either a background session or a standard session, whichever you prefer.
Which to use depends on the details of your networking. If, for example, you’re downloading a small number of huge files, a background session would still make sense. That’s what it was originally designed for, and it works well for that. OTOH, if you have to do a lot of interactive back and forth with your server, a standard session is a much better choice.
The main thing to watch out for here is expiry. As is normal for background execution, there’s no guarantee that you’ll get all the time you need.
Are there good Apple examples of doing that?
I dunno about good but there is an example (-: Check out Refreshing and Maintaining Your App Using Background Tasks.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"