I track the user's location and ask for permission when my load first loads using this:
locationManager.requestAlwaysAuthorization() locationManager.startUpdatingLocation()
If the user denies, but later changes their mind by enabling the configuration option in my app, how do I ask again? For example, I have a switch for auto detecting the user's location so when they enable it, I am trying to do this:
@IBAction func gpsChanged(sender: UISwitch) { // Request permission for auto geolocation if applicable if sender.on { locationManager.requestAlwaysAuthorization() locationManager.startUpdatingLocation() } }
But this code doesn't seem to do anything. I was hoping it would ask the user again if they want to allow the app to track the user's location. Is this possible?
The OS will only ever prompt the user once. If they deny permission, that's it. What you can do is direct the user to the Settings for your app by passing UIApplicationOpenSettingsURLString to UIApplication 's openURL: method. From there, they can re-enable location services if they wish.
The object that you use to start and stop the delivery of location-related events to your app.
How to check app permissions on your iPhone. To check your app permissions, go to Settings —> Privacy. A list of different categories, such as Location Tracking, Bluetooth, Contacts, Microphone, Photos, and more will appear. You can click on each specific category to see which apps have access to that data.
The OS will only ever prompt the user once. If they deny permission, that's it. What you can do is direct the user to the Settings for your app by passing UIApplicationOpenSettingsURLString
to UIApplication
's openURL:
method. From there, they can re-enable location services if they wish. That said, you probably shouldn't be too aggressive about bugging them for the permission.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With