iOS: App is not asking user's permission while installing the app. getting kCLAuthorizationStatusNotDetermined every time - Objective-c & Swift
I was facing the same issue, after re-installing my app it was returning kCLAuthorizationStatusNotDetermined
whenever checking for [CLLocationManager authorizationStatus]
and the app didn't even show up in Settings > Privacy > Location Services.
The authorization dialog that iOS prompts user to approve access to location services is triggered on [locationManager startUpdatingLocation]
which in your case is never called (shouldFetchUserLocation
will be always NO
).
Miguel C.'s solution seems like a good fix, will try that.
Edit for iOS8.x
When iOS8 came it brought little change in the way CLLocationManager is used. As mentioned few times in other answers it requires additional step comparing to iOS7. Today I faced the issue myself and found this article (it's been referenced from multiple other questions but it completes my earlier answer). Hope it helps!
Unable to get the permission prompt from CLLocationManager
Your CLLocationManager
object is local object and thus will be deallocated immediately after it falls out of scope. Make it a class property and then asynchronous processes like requesting authorization and determining the location will have a chance to run.
Location access - App is not asking for user permission to access location - iOS 11
I have gone through the Apple documentation and found the solution for this question.
Apple has changed few guidelines to get user location.
Here is the Video Link: Apple- What's New in Location Technologies
Full code for location access in Swift & Objective-C both
Solution:
Now we need to add three Authentication Key into Plist:
- NSLocationAlwaysAndWhenInUseUsageDescription
- NSLocationWhenInUseUsageDescription
- NSLocationAlwaysUsageDescription
Plist will look like :
And Authentication message screen will look like:
Full code for location access
My CoreLocation based Swift app is not asking user's permission to access location
Move LocationManager.requestAlwaysAuthorization()
to the viewDidAppear
method.
EDIT:
Ok, you are asking requestAlwaysAuthorization
but in info.plist you set the When in usage...
key entry, so change the requestAlwaysAuthorization
to the requestWhenInUseAuthorization
Location Services not working in iOS 8
I ended up solving my own problem.
Apparently in iOS 8 SDK, requestAlwaysAuthorization
(for background location) or requestWhenInUseAuthorization
(location only when foreground) call on CLLocationManager
is needed before starting location updates.
There also needs to be NSLocationAlwaysUsageDescription
or NSLocationWhenInUseUsageDescription
key in Info.plist
with a message to be displayed in the prompt. Adding these solved my problem.
For more extensive information, have a look at: Core-Location-Manager-Changes-in-ios-8
How to check location authorization status at the click of a button in iOS 14?
You're code works - but have you remembered to add the privacy usage descriptions to the info.plist file?
Add these two entries in the file with your own explanation in the value field, then it should popup in the simulator:
- Privacy - Location Always and When In Use Usage Description
- Privacy - Location When In Use Usage Description
Related Topics
Using Audiobufferlist with Swift
Passing Data to View Controllers That Are Embedded in Container Views
How to Throttle Search (Based on Typing Speed) in iOS Uisearchbar
Document Directory Path of Xcode Device Simulator
Simple and Clean Way to Convert JSON String to Object in Swift
In iOS 12, When Does the Uicollectionview Layout Cells, Use Autolayout in Nib
Uitableview with Static Cells Does Not Appear
How to Simultaneously Satisfy Constraints - No Constraints in Place
iOS 8 Swift - Tableview with Embedded Collectionview
iOS 7 Status Bar Collides with Navigationbar
Swift Default Alertviewcontroller Breaking Constraints
Get Device Location (Only Country) in iOS
Xcode 7 Swift 2 Impossible to Instantiate Uiviewcontroller Subclass of Generic Uitableviewcontroller
How to Turn a Cvpixelbuffer into a Uiimage
App Rejected Because of Advertisingidentifier in Facebook Sdk and Flurry Sdk