3

I just finished developing an app that interacts with the Beacons and User location.

I ask for locationManager the requestAlwaysAuthorization permission and I have added in the plist NSLocationAlwaysUsageDescription property with my description; everything works perfectly!!!

I realized that: if a user does not accept the requested permission, iOS disables localization always and when in use, making very limited the use of the app.

I wish that if a user refuses the requestAlwaysAuthorization automatically being asked requestWhenInUseAuthorization permission!

This is possible with some native method or I have to handle the request for another permission?

Thanks to all!

EDIT: How do apps like Shazam or Facebook to have three choices "Never," "When in use" and "Always" in the location settings? Surely there is a way to present them to the user?!?!

weso
  • 189
  • 3
  • 14

1 Answers1

3

You can't do that. When in doubt, please always head to the Apple documentation.

https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instm/CLLocationManager/requestAlwaysAuthorization

After requestAlwaysAuthorization is finished (the user accepted/denied), the status is changed to ether kCLAuthorizationStatusDenied or kCLAuthorizationStatusAuthorized(or some other, doesn't matter).

Furthermore, both requestAlwaysAuthorization and requestWhenInUseAuthorization both have such logic (described in the documentation)

If the current authorization status is anything other than kCLAuthorizationStatusNotDetermined, this method does nothing and does not call the locationManager:didChangeAuthorizationStatus: method.`

If the user denies the requestAlwaysAuthorization the status is changed to kCLAuthorizationStatusDenied and both request authorizations will be ignored in future.

michal.ciurus
  • 3,616
  • 17
  • 32
  • ok. But how do apps like Shazam or Facebook to have three choices "Never," "When in use" and "Always" in the location settings? Surely there is a way to present them to the user! – weso Jan 21 '15 at 17:22
  • I've installed Facebook and it just asked me for "when in use" permission. I'm pretty sure that you only have one chance. Let's say that you want to ask the user for whenInUseAuth and he agrees. If you want to upgrade from whenInUse to always, you should communicate to the user that he should do that in iOS settings like explained here:http://stackoverflow.com/questions/25188965/ios8-location-how-should-one-request-always-authorization-after-user-has-grante – michal.ciurus Jan 21 '15 at 17:47
  • Ok I'll try this solution, I don't like the idea to link the user to Settings. It 'really absurd this fact – weso Jan 22 '15 at 10:34
  • Did I answer your question ? – michal.ciurus Feb 01 '15 at 22:11