cllocationmanager - CLLocation Manager in Swift to get Location of User

I am trying to convert an old app in ObjC to Swift as a practice exercise and have ran in to some issues. The way I had it in the old app, it was establishing the CLLocation Manager and then I would use:manager = [[CLLocationManager alloc]init];manager.delegate = self;manager.desiredAccuracy = kCLLocationAccuracyBest; [manager startUpdatingLocation]which would call automatically:-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{}and from there I could ext...Read more

CLLocationManager in iOS9 giving incorrect locations (iOS8 is OK)

We experience some weird issues on the locations from CCLocationManager starting from iOS9. iOS 7-8 has no issues. The weird locations cause errors in the app. The app is used while driving a car and we have about 50 test users in TestFlight and some of them are reporting these issues.The app reacts on location updates, each location update, each 25m and each 50m there is something to do. For test I've stored all these locations in an array. Our test users have a button which will send the history in GPX format to me by mail.For example the fol...Read more

cllocationmanager - Why are my iBeacons not being detected?

I set up my CLLocationManager as follows self.locationManager.delegate = self; if ([CLLocationManager isMonitoringAvailableForClass:[CLBeaconRegion class]]) { [self.locationManager startMonitoringForRegion:self.region]; } else { NSLog(@"CLBeaconRegion monitoring not available"); } if ([CLLocationManager isRangingAvailable]) { [self.locationManager startRangingBeaconsInRegion:self.region]; } else { NSLog(@"CLBeaconRegion ranging not available"); }locationManager:didEnterRegion: and location...Read more

cllocationmanager - Managing LocationManager didUpdateLocation

Two questions:I have LocationManager called from a Singleton. When I run the following code it cycles indefinitely from the moment it is launched. Which I suspect is proicessor and espacially battery intensive. What is the approved method to kill this loop once you have an accurate enough fix?Can I adapt this to return the Longitude/Latitude (long/lat)? (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { int degrees = newLocation.coordinate.latitude; ...Read more

CLLocationManager location update callBack on ios9

I have developer an walk app that can record distance, on ios7,ios8,the distance almost fine although some time not accurate,but on ios9.0, the distance often too larger, so I check - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)Locations method, and find some time timestamp of new location early than some previous location, it means location from callBack are not sorted by timestamp, why is that and how deal with it, Thanks in advance...Read more

CLLocationManager geofencing not working

I am trying to get geofencing working in CoreLocation but even though I am standing right on top of the lat/long point, didEnterRegion never gets called. Here's my code: override func viewDidAppear(_ animated: Bool) { myLocationManager = CLLocationManager() myLocationManager.delegate = self myLocationManager.desiredAccuracy = kCLLocationAccuracyBest if CLLocationManager.authorizationStatus() == .notDetermined { myLocationManager.requestAlwaysAuthorization() } else if CLLocationManager.authorizationStatus() == .authorizedAl...Read more

swift2 - CLLocationManager - fatal error: unexpectedly found nil while unwrapping an Optional value

I have a little problem with CLLocationManager. When I click on IBAction "addPlace", the app crash. I don't see the problem, and I don't understand why the app crash.Thank you in advance for your response.class Map: UIViewController, CLLocationManagerDelegate { // Outlets @IBOutlet weak var mapView: MKMapView! @IBOutlet weak var BTNAdd: UIButton! // Variables var positionManager = CLLocationManager() var geoCoder : CLGeocoder! var placemark : CLPlacemark! var name: String = "" var address: String = "" var longitude...Read more

swift2 - Swift 2 CLLocationManager Error updating

i updated Xcode 6 to Xcode 7 beta with Swift 2. I get this error and i can't find out how to fix it, please help me. Thanks. This is my code : func locationManager(manager: CLLocationManager, didUpdateLocations locations: [AnyObject]) { let location = locations.last as! CLLocation let center = CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude) let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01)) self.map.setRegion(regi...Read more

cllocationmanager - Localizing the user on iOS 8

Hullo,I am starting to port my apps to iOS 8 and I soon bounced into a problem with CLLocationManager. Basically the app no longer centers the map on the user's location and instead proposed error: Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.Executing [CLLocationManager requestAlwaysAuthorization]does nothing and even inserting theNSLocationAlwaysUsageDescription key in the app’s Info.p...Read more

cllocationmanager - LocationManager still lives when switching tab

I have a TabBarApplication with four tab bar items.My third tab uses a CLLocationManager to locate where the user are and so forth.- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {[locationManager stopUpdatingLocation];NSLog(@"error%@",error);switch([error code]){ case kCLErrorNetwork: { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Please check your network connection or that you are not in airplane mode." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:ni...Read more

ios8 - iOS 8: -[CLLocationManager requestWhenInUseAuthorization] not calling delegate

I'm calling -[CLLocationManager requestWhenInUseAuthorization] on the main thread. I've set my delegate, and I supplied a value in info.plist for the NSLocationWhenInUseUsageDescription key.The dialog asking the user for access shows appropriately, but when the user taps "Allow" or "Disallow", the delegate method -[locationManager:didChangeAuthorizationStatus:] isn't being called.I'm on iOS 8, so it could be a bug...but it seems like too big a bug to go unnoticed. Any ideas what's going on?Thanks....Read more

CLLocationManager "Turn On Location Services" Cancel Button press delegate

I want to know and take some action if the user has pressed cancel button in the"Turn On Location Services" prompt. I have tried creating a breakpoint on the (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)errordelegate method but this breakpoint does not get hit.I want to know if the location services is off and the user has hit cancel so that I may not get into the same workflow again and again....Read more

CLLocationManager Deferred Updates Failing

I have an app that has worked fine in the foreground. I wanted to give it the ability to track locations in the background. However, it is not deferring updates.The length here is due to trying to answer questions raised in similar posts:I've gotten the pinfo settings that allow the application to go into the back ground without crashing. Before going into the background I call: [locationManager allowDeferredLocationUpdatesUntilTraveled:CLLocationDistanceMax timeout:CLTimeIntervalMax] ;But this delegate function gets called immediately:- (vo...Read more

cllocationmanager - recieving location updates after app is terminated

I need to keep track of the user location all the time (but not drain the battery).I understand the only way to get updates after app is terminated is using startMonitoringSignificantLocationChanges.From Apple's Location Awareness Programming Guide on startMonitoringSignificantLocationChanges: If you start this service and your application is subsequently terminated, the system automatically relaunches the application into the background if a new event arrives. In such a case, the options dictionary passed to the application:didFinishLaunch...Read more

cllocationmanager - Implement CLLocationManagerDelegate methods in Swift

I've been trying to get this to work for awhile now, and I've come here to ask- how do I go about with using the CLLocationManagerDelegate methods in Swift? I've put this at the top of my class:var locationManager = CLLocationManager()I've put the following into my viewDidLoad method:locationManager.delegate = selflocationManager.distanceFilter = kCLDistanceFilterNonelocationManager.desiredAccuracy = kCLLocationAccuracyBestlocationManager.startUpdatingLocation()And I've tried using these delegate methods with no avail:func locationManager(manag...Read more