Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What conditions make iOS 13 to ask user to grant 'Always' location access?

Core functionality of my app is updating location data in background mode. In iOS 13, when we calling locationManager.requestAlwaysAuthorization(), system asks user to choose among variants 'Never', 'Permit Once' and 'When in use'.

screenshot 1

If user grants 'When in use' access, our app will be able to work only in foreground.

The thing i can't understand is following: Sometimes when app goes into background and after a while became active and goes into background again, iOS 13 asks user to change location access to 'Always'

see screenshot 2

What should my app to do to make iOS 13 to show this dialog to user? (I want to do it, when my app goes into background at first time)

P.S. I know, i can use some custom alert with text like "please, go to system settings and adjust location access for this app to 'Always' mode". But i need to know, is there any way to use "native system flow" as described above?

Thanks!

like image 771
sugar baron Avatar asked Oct 01 '19 12:10

sugar baron


People also ask

What does always allow location mean Iphone?

“Always Allow” meaning an app could be collecting your real-time location both while the app was visible on the screen AND in the background even when the app was not visible on the screen. “Don't Allow” meaning that apps could never collect your real-time location.

How do I ask for location permissions in IOS?

To request authorization, call requestWhenInUseAuthorization or requestAlwaysAuthorization , depending on the authorization status your app needs. See Choosing the Location Services Authorization to Request for more information about deciding what type of authorization to request.

Why is every app asking for location?

Maps & Travel: Navigation apps require your location for turn-by-turn directions, and most travel apps use your location to help you find cool places nearby. Plus, ride-sharing apps (like Uber and Lyft) use your location, so drivers know where to pick you up.


1 Answers

@Claudio's answer helps me to solve my problem. I've found that it is able to access location in background having 'When in use' permission. To do so, you must set locationManager.showsBackgroundLocationIndicator = true.

Here is my locationManager adjustment:

        let locationManager = CLLocationManager()
        if #available(iOS 9, *){
            locationManager.allowsBackgroundLocationUpdates = true
        }
        locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters
        locationManager.distanceFilter = kCLDistanceFilterNone
        locationManager.headingFilter = kCLHeadingFilterNone
        locationManager.pausesLocationUpdatesAutomatically = true
        locationManager.activityType = .otherNavigation
        if #available(iOS 11.0, *) {
            locationManager.showsBackgroundLocationIndicator = true;
        }
        locationManager.delegate = self
        locationManager.startMonitoringSignificantLocationChanges()
like image 138
sugar baron Avatar answered Sep 29 '22 12:09

sugar baron