location manager kCLErrorDomain code=0 error

I am not able to get current location in iPhone device. The code in ViewController is given below.

When I run the code, console shows NotDetermined and after about 5 to 7 seconds print the following error from didUpdateLocations

function:


got following error from loaction manager

Error Domain=kCLErrorDomain Code=0 "(null)"

I have following keys setup in Info.plist:

Required device apabilities

item 0 location-services

item 1 gps

Privacy - Location Usage Description Required to show your location


import UIKit

import MapKit

import CoreLocation

class MapViewController: UIViewController, CLLocationManagerDelegate {

let locationManager = CLLocationManager()

@IBOutlet weak var mapView: MKMapView!


func checkLocationAuthorizationStatus() {

let status = CLLocationManager.authorizationStatus()

if status == CLAuthorizationStatus.NotDetermined{

print("NotDetermined")

locationManager.requestWhenInUseAuthorization()

CLLocationManager.locationServicesEnabled()

locationManager.requestLocation()

}else {

print("Problem with authorization")

}

}

override func viewDidLoad() {

super.viewDidLoad()

locationManager.delegate = self

checkLocationAuthorizationStatus()

}


func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {

print("got location update")

}


func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {

print("got following error from loaction manager")

print(error.description)

}

override func viewDidAppear(animated: Bool) {

super.viewDidAppear(animated)

}


func locationManager(manager: CLLocationManager,

didChangeAuthorizationStatus status: CLAuthorizationStatus){

print("didChangeAuthorizationStatus")

checkLocationAuthorizationStatus()

}


override func didReceiveMemoryWarning() {

super.didReceiveMemoryWarning()

}

}

I'm having the exact same issue, with very similar code. Anyone know why?


One thing I've noticed is that I can't get the requestWhenInUseAuthorization call to prompt the watch or the phone for location permission.

Getting the same issue here. The location manager starts to error after about 10 seconds. This seems to be a bug in iOS 9 (unless there is some new setting we do not know about...). Everything works perfectly in iOS 8.4.1. Also noticing that UIMapView showsUserLocation stops updating after about 10 seconds.

location manager kCLErrorDomain code=0 error
 
 
Q