Reputation: 33
I'm writing a navigation app that tracks the user location.
In order to continue showing notification about the route (when phone is locked, answering the phone, etc.) - i also need to continue tracking the location while the app is in the background: (Capabilities>Background Modes>Location updates, locationManager.allowsBackgroundLocationUpdates = true)
I have been struggling with this question for a very long time and read a lot about it, but couldn't find the answer i'm looking for. i have implemented both options :
(locationManager.requestWhenInUseAuthorization()
):
Whenever the application is in the background there is the additional blue location alert bar on top of every application.
locationManager.stopUpdatingLocation()
- since i need
them in the background.locationManager.requestAlwaysAuthorization()
):After a while my users get the background location frightening prompt message. Example:
‘APP' has been using your location in the background. Do you want to continue allowing this?
locationManager.stopUpdatingLocation()
when terminating the app - on
applicationWillTerminate(_ application: UIApplication)
Seems that both are not only bad UX that can discourage users, but also very uncommon in other location based apps.
I cannot figure out what i'm missing here.
Upvotes: 3
Views: 3530
Reputation: 2540
Both mechanisms you mentioned are in place by the OS in order to protect users. They are not only alerting the user that an application in on the background retrieving its location, but also that something might be consuming battery when not needed anymore.
There's no way to avoid this, so you should decide which one fits best according to the needs of your application.
For instance, some apps give directions about a route, these apps tend to have the blue banner at the top (see Google Maps or even Apple Maps).
On the other hand, some other apps are interested in getting location updates at all times (e.g. fitness apps or apps that track all your movement, see Moves). In this situation the user will be alerted once about the fact that this app is continuously using its location on the background, if they accept it they won't be bothered again (iOS 8 and above).
Here's some info regarding option 2 from Apple staff:
A few days after the app obtains the "always" authorization and starts using location services in the background, the user will be asked to confirm once again that they still want this app to track their location in the background.
There is no developer action that can be taken to avoid this confirmation if the app is obtaining users' location in the background.
Source: About privacy and Location Services in iOS 8 and later
Upvotes: 2