Leveraging the Power of Background Execution (Pt. 2)

Felipe Ricieri
4 min readSep 6, 2020

How to effectively distribute and defer work from the foreground to the background.

Shot by Charles Deluvio, in Unsplash

Previously, we had a good overview of how the Background Execution is handled after iOS 13. Now is time to get our hands on it. In this article I will share with you my own implementation and my findings.

I have set up an app to demonstrate how the background tasks works in practice. It follows Apple’s Project Sample (you can find here), but it is a bit simpler. It is called Footprints.

It mainly schedules 2 tasks (one of each type) when the app goes into the background and when the task is performed, it records in a local storage the time of execution and the task nature.

My goal was to show when the system was opening my app to perform what task. Let me walk you through it step by step:

Getting started

There are some configuration to be set in order to add tasks to the Background Scheduler. Apple has a great documentation for that with helpful resources (which you can check here). Overall, you must:

  • In your Xcode, under the Project Settings “Signing & Capabilities” Tab, add a Background Mode Capability;
  • Tick the Background Fetch and/or Background Processing box;

--

--