Reputation: 9
I am working on a navigation application where locations are at the forefront. According to the information I have obtained, if the user allows the "NSLocationAlwaysAndWhenInUseUsageDescription" permission on iOS devices, the application can access location changes without any problem while the application is in the background. But when I request this permission for the first time and select the "Only when using the app" option, I cannot access the location changes, so it does not work. When the user exits the app, iOS shows a message and asks for permission again, and when I select the "always" option, I can access location changes in the background without any problem. I can't understand whether my problem is due to permissions or my user experience plan is wrong. If you have any information, can you share it with me?
Technologies I use:
Upvotes: -1
Views: 722
Reputation: 438122
The flow that you experience is correct. You can request “always” access, but the user is in ultimate control of whether they grant it or not.
Unfortunately, there is a long history of apps abusing “always” access (draining the device’s batteries, using background tracking information for purposes that are not necessarily in the user’s best interests, etc.). So, there are good reasons why the OS leaves the user in ultimate control of whether apps can track location information in the background, or not.
So, if background location tracking is truly essential for the user (not just something that the app would like to capture for its own purposes) we generally do two things:
Before asking for location access (or in the usage string), we make the case for why “always” permission is essential for the use of the app.
An interesting design choice is when you ask for this permission. If the app blithely requests “always” permission when the app first launches, often the user will not have a context for deciding whether to grant this privilege or not, and more likely than not, they will decline. If you defer it to a point that the user has experience enough of the app to appreciate the value of granting this privilege, they may be more inclined to accept it.
When relaunching the app, we can check for the authorization status, and if it has been set to “once” or “only while the app is running”, you can present a UI that reiterates why the user would want to grant “always” permission, and if they agree, redirect them to the “Settings” app to change the permission.
Note, I would note some caution about nagging the user about this every time they launch the app unless it is absolutely essential, from the user’s perspective. It sounds like this may be the case in your app, but just appreciate that the App Store review process will view this with a jaundiced eye, and if you repeatedly ask for background location permissions where it is more of a “nice to have” feature, your app may be rejected.
Upvotes: 1