Before we can request permissions so that we can use the location of the user, we need to add a description of what we will use the location for. Since the release of iOS 11, we are no longer allowed to just ask for permission to track the location of the user all the time; the user has to be able to give us permission to only track their location while they are using the app. We can add the description to the info.plist file as follows:
- Open info.plist with the XML (text) editor that can be found in the MeTracker.iOS project.
- Add the NSLocationWhenInUseUsageDescription key, along with a description.
- Add the NSLocationAlwaysAndWhenInUsageDescription key, along with a description, as shown in the following code:
<key>NSLocationWhenInUseUsageDescription</key>
<string>We will use your location to track you</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string...