I am new to the tvOS platform. I want to know how to get current location latitude and longitude at the application launch. I am writing this code to get the location coordinate.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
dispatch_async(dispatch_get_main_queue()) { () -> Void in
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager.delegate = self
self.locationManager.requestLocation()
self.locationManager.requestWhenInUseAuthorization()
}
return true
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
locationValue = manager.location?.coordinate
print("=========didUpdateLocations==========Latitude>>>>>",locationValue.latitude)
print("=========didUpdateLocations==========Longitude>>>>",locationValue.longitude)
}
func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
print("localizedDescription===================",error.localizedDescription)
}
This code provide the coordinate after the view controller loads. While my requirement is that I want to get coordinate before loading the view controller. Can i enable location service programmatically for single application?
It requires setting the app information and grants, see the discussion Here
I also found the solution and explanation for this identical question Here