Questions tagged [cllocationmanager]

The CLLocationManager class defines the interface for configuring the delivery of location- and heading-related events to your application

The CLLocationManager class defines the interface for configuring the delivery of location- and heading-related events to your application. You use an instance of this class to establish the parameters that determine when location and heading events should be delivered and to start and stop the actual delivery of those events. You can also use a location manager object to retrieve the most recent location and heading data.

A location manager object provides support for the following location-related activities:

  • Tracking large or small changes in the user’s current location with a configurable degree of accuracy.
  • Reporting heading changes from the onboard compass. (iOS only)
  • Monitoring distinct regions of interest and generating location events when the user enters or leaves those regions.
  • Deferring the delivery of location updates while the app is in the background. (iOS 6 and later only)
2729 questions
43
votes
2 answers

Replacement for "purpose" property of CLLocationManager

In iOS 6, the purpose property of CLLocationManager, to describe the reason for using location services (@property(copy, nonatomic) NSString *purpose) has been deprecated. What replacement, if any, is proposed by Apple?
Guillaume
  • 21,685
  • 6
  • 63
  • 95
41
votes
13 answers

CLLocationManager on iPhone Simulator fails with kCLErrorDomain Code=0

CLLocationManager on iPhone Simulator is supposed to fake Cupertino (isn't it?) but it does NOT, it fails with kCLErrorDomain Code=0 instead. LocationManager's delegate receives the message didFailWithError. This method is implemented to log the…
albertamg
  • 28,492
  • 6
  • 64
  • 71
40
votes
7 answers

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

I am able to place annotations on my MKMapView by using latitude and longitude, however, my feed coming in that I need to use location for is using street addresses instead of Lat and Long. e.g 1234 west 1234 east, San Francisco, CA ... Would this…
Romes
  • 3,088
  • 5
  • 37
  • 52
38
votes
3 answers

Battery drain when using CoreLocation Significant Location Monitoring & CoreBluetooth

We've released an application which runs in the background and uses CoreBluetooth & CoreLocation to automatically save your parking location. At a high level our app just looks for a CoreBluetooth disconnect event and turns on GPS until we get an…
38
votes
8 answers

CLLocationManager startUpdatingLocation not calling locationManager:didUpdateLocations: or locationManager:didFailWithError:

I'm trying to use the CLLocationManager framework in my iOS project to access the user's location but when I call [locationManager startUpdatingLocation] neither locationManager:didUpdateLocations: or locationManager:didFailWithError: are getting…
ja.
  • 467
  • 1
  • 5
  • 16
37
votes
1 answer

How to get Current Location using SwiftUI, without ViewControllers?

I've prepared in my project the following class to retrieve the user current location: LocationManager.swift import Foundation import CoreLocation class LocationManager: NSObject { // - Private private let locationManager =…
Salva
  • 707
  • 2
  • 9
  • 18
37
votes
8 answers

didUpdateLocations not called

I'm trying to get my current location, but the break point in didUpdateLocations is never being called. LocationManager: locationManager = [[CLLocationManager alloc] init]; [locationManager setDelegate:self]; [locationManager…
mikeholp
  • 965
  • 3
  • 11
  • 14
36
votes
3 answers

How to check if location services are enabled for a particular app prior to iOS 4.2?

How can I check if the user has allowed location for mu app? Normally I would use authorizationStatus method of the CLLocationManager class, but it is only available in iOS 4.2 and newer. Is it possible to achieve this somehow while still using SDK…
pajevic
  • 4,607
  • 4
  • 39
  • 73
36
votes
1 answer

MBProgressHUD blocking user interaction

My application has a MBProgressHUD on the screen while the CLLocationManager is getting the user current location at a separate thread in the background. Sometimes the location process start to take so long and obviously I would like to let the user…
vilelam
  • 804
  • 1
  • 11
  • 19
34
votes
3 answers

How to find your current location with CoreLocation

I need to find my current location with CoreLocation, I tried multiple methods but so far my CLLocationManager has only returned 0's.. (0.000.00.000). Here's my code (updated to work): Imports: #import…
Aleksander Azizi
  • 9,829
  • 9
  • 59
  • 87
33
votes
6 answers

Location tracking stops after a while when app is in the background

I've created a simple app which tracks user location and creates local notification for every time location is updated. I enabled the background modes below, let locationManager = CLLocationManager() open override func viewDidLoad() { …
Okan Kocyigit
  • 13,203
  • 18
  • 70
  • 129
32
votes
3 answers

Swift LocationManager didChangeAuthorizationStatus Always Called

I have a view controller which implements the CLLocationManagerDelegate. I create a the CLLocationManager variable: let locationManager = CLLocationManager() Then in the viewDidLoad, I set properties: // Set location manager…
Mike Walker
  • 2,944
  • 8
  • 30
  • 62
32
votes
5 answers

Tracking multiple (20+) locations with iOS geofencing

An iOS application uses the geofencing for notifying the user about predefined nearby locations. The application is allowed to miss some location (the user is not getting a notification about a nearby location), but it is desirable to keep the…
silentser
  • 2,083
  • 2
  • 23
  • 29
31
votes
13 answers

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…
Sean Fitz
  • 335
  • 1
  • 3
  • 8
31
votes
12 answers

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

This my code...... -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { location_updated = [locations lastObject]; NSLog(@"updated coordinate are %@",location_updated); latitude1 =…
user3378632