This course is available as part of the raywenderlich.com Professional subscription. To learn more click here
Pro

Background Tasks in iOS

Jun 15 2021 · Video Course (16 mins) · Intermediate

Launching your iOS app in the background and performing some tasks wasn’t all that easy. However, in iOS 13 Apple introduced an all new framework called Background Tasks. It’s incredibly powerful framework that allows you to launch your iOS application in the background and perform some important tasks ready when your users return. In this course we’re going to explore the all new framework and build out a sample project to update a list of music from the iTunes API.

3.6/5 5 Ratings

Version

  • Swift 5, iOS 14.4, Xcode 12.5

Background Tasks in iOS

To get started using the Background Tasks framework, we need to setup our project capabilities. These capabilities allow Xcode to recognise that you would like to use background tasks. You also need to create some new values within the Info.plist.

1

Background Tasks framework requires you to register every background task that is required. You do this via identifiers and registering with the framework. You also need to declare these identifiers inside the Info.plist.

2

Your background task is going to hit this API and download an updated list from the API, so that when a user returns they can see the latest music very quickly. In this episode you will write the logic to handle this refresh.

3

In the Background Task framework we also get access to a processing task, this is primarily used for intensive tasks such as training an ML model or cleaning a database. In this episode, explore scheduling a processing task and how this could work for you in your iOS app.

4

In this episode, explore all the ways of testing a background task. It can be quite daunting when you have done all this logic and wonder what is the best way to make sure this happens in the cirumstances you want.

5

Who is this for?

This course is for anyone interested in running background tasks in their iOS application or just learning about the framework introduced by Apple.

Covered concepts

  • Background Tasks framework
  • Launching tasks in the background

Contributors

Comments