John Cashew
John Cashew

Reputation: 1084

Changing requestAlwaysAuthorization to requestWhenInUseAuthorization not working

My app used to use requestAlwaysAuthorization with an Info.plist entry for NSLocationAlwaysUsageDescription.

I changed it to use a requestWhenInUseAuthorization with an Info.plist entry for NSLocationWhenInUseUsageDescription.

After the change the app can no longer get the location. It only receives a didChangeAuthorizationStatus of kCLAuthorizationStatusNotDetermined. The OS does not prompt for a change in permission (which makes sense because it already has permission for always. The settings menu for the app does not contain an entry for location information (which would allow me to revoke or approve it). didFailWithError is never called.

I then switched back to using requestWhenInUseAuthorization with an Info.plist entry for NSLocationWhenInUseUsageDescription and restarted the app. The OS prompts for a change in permission to always. I grant it and the location starts working perfectly.

Deleting the app before reinstalling it has no effect.

I am using IOS 9.2. This happens on a real iPhone and on the simulator. I have the simulator's location set to Apple.

Upvotes: 1

Views: 936

Answers (1)

Echizzle
Echizzle

Reputation: 3459

Location Manager can be a real hit or miss on the simulator, for me at least, sometimes it works well and sometimes it doesn't. Have you tried running it on a device?

Upvotes: 1

Related Questions