How to get Location user with CLLocationManager in swift?

first add this two line in plist file 1) NSLocationWhenInUseUsageDescription 2) NSLocationAlwaysUsageDescription Then this is class working complete implement this import UIKit import CoreLocation @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate { var window: UIWindow? var locationManager: CLLocationManager! var seenError : Bool = false var locationFixAchieved : Bool = false var locationStatus : NSString = “Not … Read more

iOS – MKMapView place annotation by using address instead of lat / long

Based on psoft‘s excellent information, I was able to achieve what I was looking for with this code. NSString *location = @”some address, state, and zip”; CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder geocodeAddressString:location completionHandler:^(NSArray* placemarks, NSError* error){ if (placemarks && placemarks.count > 0) { CLPlacemark *topResult = [placemarks objectAtIndex:0]; MKPlacemark *placemark = [[MKPlacemark alloc] … Read more

iOS: App is not asking user’s permission while installing the app. getting kCLAuthorizationStatusNotDetermined every time – Objective-c & Swift

iOS8 has got us major API changes with the LocationsServices Assuming [CLLocationManager locationServicesEnabled] return YES, With the First Launch of the iOS App [both iOS7 and iOS8] – locationMangers(CLLocationManager) authorizationStatus preset to authorizationStatus(CLAuthorizationStatus) = kCLAuthorizationStatusNotDetermined Prompting in iOS7+ Initiate the locationManger (CLLocationManager , Strong) and set the delegates(CLLocationManagerDelegate) Now to prompt the user to use … Read more

iPhone GPS in background never resumes after pause

If you search for pausesLocationUpdatesAutomatically on the Apple forums you’ll find a recent question along similar lines which has had a response from an Apple developer. I won’t repost it directly here since it is a private forum, but the gist is that the location pausing is for instances when the user forgets that they … Read more

How to stop multiple times method calling of didUpdateLocations() in ios

While allocating your LocationManager object you can set the distanceFilter property of the LocationManager. Distance filter property is a CLLocationDistance value which can be set to notify the location manager about the distance moved in meters. You can set the distance filter as follows: LocationManager *locationManger = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.distanceFilter = … Read more

CLLocation Manager in Swift to get Location of User

You are missing two things. First, you have to ask for permission using requestAlwaysAuthorization or requestWhenInUseAuthorization(). So your viewDidLoad() should be like this: var locationManager = CLLocationManager() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. locationManager.delegate = self locationManager.desiredAccuracy = kCLLocationAccuracyBest locationManager.requestAlwaysAuthorization() locationManager.startUpdatingLocation() } Second, … Read more

didFailWithError: Error Domain=kCLErrorDomain Code=0 “The operation couldn’t be completed. (kCLErrorDomain error 0.)”

If you are using the simulator: Press command + shift + , in Xcode to open the scheme editor Select the Run scheme Go to the Options tab Check ✅ Allow Location Simulation Select a Default Location in the dropdown Selecting None as your Default Location may have caused the problem.