When we want to perform tasks in the background in an iOS app, we need to declare what we want to do in the info.plist file. The following steps show how we go about this:
- In the MeTracker.iOS project, open info.plist.
- Go to the Capabilities tab.
- Select Enable Background Modes and Location updates, as shown in the following screenshot:
We can also enable background modes directly in the info.plist file if we open it with an XML editor. In this case, we will add the following XML:
<key>UIBackgroundModes</key>
<array>
<string>location</string>
</array>