FAQ Database Discussion Community


Why does didUpdateLocations: only have one location after locationManagerDidResumeLocationUpdates:

ios8,cllocationmanager
I have location services working in iOS8. It is set for kCLLocationAccuracyBest using startMonitoringSignificantLocationChanges to restart when in the background and startUpdatingLocation for accuracy. When I set pausesLocationUpdatesAutomatically = YES, the location services get paused and resumed as expected. However, the following call to didUpdateLocations: only has one location in...

MKMapView or CLLocationManger - to determine user's current location

ios,cocoa-touch,mkmapview,mapkit,cllocationmanager
There are two classes that help regarding map plotting and determining user location - MKMapView and CLLocationManager. MKMapView has a delegate “didUpdateUserLocation” that tells the user’s current location. At the same time, CLLocationManger has a delegate “didUpdateToLocation” and it also does the same thing. My question is when to use...

GeoFenceController with CLLocationManager as singleton?

ios,singleton,cllocationmanager,locationmanager,geofencing
I have a GeoFence class. I'm debating myself whether or not it should be a singleton. My code works either way and I have read a couple of articles and posts here on SO about it. But I didn't find any good rules for when it is correct to use...

Getting user location not working?

ios,mapkit,cllocationmanager
I am new to the MapView topic.Now I am working on the map view.I am getting the san Francisco location longitude and latitude values.I am testing in the simulator.It is not showing the current location longitude and latitude values. With the help of this tutorial http://www.creativeworkline.com/2014/12/core-location-manager-ios-8-fetching-location-background/ I am developing the...

xamarin forms permission to use location iOS

ios,xamarin,geolocation,cllocationmanager,xamarin.forms
I'm using Xamarin.Forms and creating an iOS App who has a background service to get a location each 10 minutes. The code is working, my problem is when I access the App configuration on an IPad. It shows the permission for accesss the camera but not to access the current...

locationmanager.requestWhenInUseAuthorization() not working?

ios,google-maps,swift,core-location,cllocationmanager
I am trying to use location services in my IOS App but for some reason requestWhenInUseAuthorization is not working. When the user first uses the app, the prompt comes up as normal asking for permissions but then when you open the app a second time, for some reason didChangeAuthorizationStatus method...

iOS Location Services asks on app open

ios,objective-c,xcode,cllocationmanager
Just trying to add location services to my app (in ObjC). I only want the permissions prompt to appear when I am about to use it, however the prompt appears when I first open the app. My impression was that the prompt would only appear when startUpdatingLocation was called on...

location updating in simulator but not in device

ios,gps,cllocationmanager
I am trying to get the user's updated location by using core location framework.It is working in simulator, but not in ipad/iphone.I am using the following code to get it. In simulator, i am using freeway drive. -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation: (CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { CLLocation *currentLocation=newLocation; NSLog(@"location : %@",currentLocation);...

Getting many location updates

swift,cllocationmanager
I'm implementing user location for IOS using swift. This is my code. import UIKit import CoreLocation class localizationViewController: UIViewController, CLLocationManagerDelegate { let locationManager = CLLocationManager() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. self.locationManager.delegate = self self.locationManager.desiredAccuracy = kCLLocationAccuracyBest self.locationManager.distanceFilter = 500 self.locationManager.requestWhenInUseAuthorization()...

Beacon / IOS CLLocationManager get current region

ios,swift,cllocationmanager,ibeacon
I'm doing a program who is looking for beacon, I implemented CLLocationManager and my apps works except one point. I'm calling startMonitoringForRegion() in order to get the didEnterRegion/didExitRegion callback. Inside these function I'm doing startRangingBeaconsInRegion()/stopRangingBeaconsInRegion() in order to get precise information when the user is in the beacon area. My...

CLLocationManager not requesting permission from user

ios,swift,cllocationmanager
I am working on an app in Swift which has to get the GPS coordinates of the user. I have added the keys (NSLocationWhenInUseUsageDescription and NSLocationAlwaysUsageDescription) to info.pList like so: <key>NSLocationWhenInUseUsageDescription</key> <string>Location is required to find your coordinates</string> <key>NSLocationAlwaysUsageDescription</key> <string>Location is required to find your coordinates</string> I have also added...

How to get background updates for iBeacons without using locationManager didEnterRegion

ios,objective-c,cllocationmanager,ibeacon
I'd like to get background updates to my app for beacon proximity (entering a region) but I've just read on the Apple docs that: When testing your region monitoring code in iOS Simulator or on a device, realize that region events may not happen immediately after a region boundary is...

CLLocationManager: Unexpectedly Found Nil While Unwrapping an Optional Value

ios,swift,cllocationmanager
Here's my code in ViewController.swift: import UIKit import Alamofire import SwiftyJSON import MapKit import CoreLocation import TwitterKit class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate { @IBOutlet weak var myMap: MKMapView! @IBOutlet weak var counterLabel: UILabel! var manager = CLLocationManager() override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the...

How to tell if CLLocationManager is Monitoring Significant Location Changes

mapkit,core-location,cllocationmanager
I'm updating an app which monitors for significant changes to the user's location using CLLocationManager. I allow the user to toggle this option on or off, setting startMonitoringSignificantLocationChanges and stopMonitoringSignificantLocationChanges appropriately. The problem is when the user reopens the app I need to know if the app is currently monitoring...

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

ios,swift,mkmapview,cllocationmanager
I have a problem because my app crash when i try to get position user and have permission in my .plist this my code. import UIKit import MapKit import CoreLocation class mapClass : UIViewController,MKMapViewDelegate,CLLocationManagerDelegate{ var location4 = CLLocation() var lm = CLLocationManager () @IBOutlet var propMapa: MKMapView! lm.delegate=self lm.desiredAccuracy =...

allowsBackgroundLocationUpdates in CLLocationManager in iOS9

ios,swift,core-location,cllocationmanager,ios9
I'm using CoreLocation framework in my app in Xcode7(pre-released),and I noticed that there is a newly added property called allowsBackgroundLocationUpdates in CLLocationManager class. What's the relationship between this property and the location updates in the Background Modes of the Capabilities tab. What's the default value of it and does it...

Can't Determine When User Doesn't Allow Location Services

ios,swift,core-location,cllocationmanager
I'm requesting the user to turn on location services. I want to know when a user clicks Don't Allow so I can handle some notifications. However, the didFailWithError or didChangeAuthorizationStatus methods are not being called when I click Don't Allow. I know this nothing is printed in the logger. I've...

Can we measure the data of M7/M8 while the iPhone is unawakened in the CLVisit delegate method?

ios,objective-c,iphone,cllocationmanager,cllocation
Can I write the code in this method to get the M7's data and does it useful while I don't run the app? -(void)locationManager:(CLLocationManager *)manager didVisit:(CLVisit*)visit { } ...

CLLocationManager - kCLErrorDomain

ios,swift,cllocationmanager
I have a CLLocation manager. It works fine. locManager = CLLocationManager() locManager.delegate = self locManager.desiredAccuracy = kCLLocationAccuracyBest locManager.requestWhenInUseAuthorization() locManager.startUpdatingLocation() And of course, I have the delegate methods: func locationManager(manager: CLLocationManager, didFailWithError error: NSError) { println("didfail") println(error) } func locationManager(manager:CLLocationManager, didUpdateLocations locations:[AnyObject]) { println("location manager called..") let locationLast =...

Remove CLBeaconRegion from monitoring depending on current location

ios,geolocation,cllocationmanager,ibeacon,clbeaconregion
So I was looking for a way to remove a BeaconRegion from the monitored regions depending on how far it is from my current location. I though I could use the center property, though I think I'm missing something... Because the latitude/longitude values are like not valid... po [region center]...

Is there any good way to know when CLLocationManager's startMonitoringForRegion has completed?

ios,objective-c,cllocationmanager,ibeacon
From CLLocationManager.h: /* * startMonitoringForRegion: * * Discussion: * Start monitoring the specified region. * * If a region of the same type with the same identifier is already being monitored for this application, * it will be removed from monitoring. For circular regions, the region monitoring service will prioritize...

Where to store app location data?

ios,objective-c,swift,core-location,cllocationmanager
I have an app that needs to retrieve the longitude/latitude coordinates of the device when it's opened, and then communicate with the server using these coordinates. My app is based on a UITabBarController so has different pages, some of which need to use this location data. I also need to...

Trying to send POST parameters with latitude and longitude

ios,objective-c,location,cllocationmanager
I am trying to send some parameters to my phpMyAdmin tables that contains a filed called latitude and longitude. Since then, i need to obtain the device coordinates and transform them into a string. I have followed the Ray Wenderlich tutorial but i am still getting "nil" in my parameters....

Indoor Navigation using I-Beacon

ios,cllocationmanager,ibeacon,indoor-positioning-system
I am doing an Indoor Navigation using I Beacon. I want to know the current location of the user. Is there any property for beacon like proximity or accuracy where i will get the distance of the beacon from the userLocation. Please help me to get the distance of the...

iOS update location even when app is terminated

ios,background,cllocationmanager
I'm trying to update users location even when app is terminated. I added maps, and background mode --> Location update to my .plist, and I set an local notification that will fire when location is updated. But it never got fired. I have this in AppDelegat.h: @interface AppDelegate : UIResponder...

Getting Location Services to work in IOS 8

ios,objective-c,authorization,cllocationmanager
I am trying to update some old code to get it to work in IOS 8. I have read through Location Services not working in iOS 8 but I am still very confused as to how to correctly implement the methodology. I have added in <key>NSLocationWhenInUseUsageDescription</key> <string>The spirit of stack...

startMonitoringSignificantLocationChanges called every 47 sec while application in background

ios,objective-c,cllocationmanager
startMonitoringSignificantLocationChanges is added for background and delegate "- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations" is called in every 47 sec while application in background. If application is on same place i don't want to hit the server api to submit the location, if location has changed then I want to submit the...

Can I set custom location in CLLocationManager in iPhone

ios,swift,core-location,cllocationmanager
I am working on a compass app showing true heading (i.e directs towards true north) which uses location as described by apple documentation IMPORTANT This property contains a valid value only if location updates are also enabled for the corresponding location manager object. Because the position of true north is...

iOS 8 CLLocationManager enterRegion: not getting called if use requestWhenInUseAuthorization

ios,objective-c,location,cllocationmanager,clcircularregion
I'm trying to get being called the delegate method locationManager:didEnterRegion in iOS 8 for custom region. Here is the code: self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { [self.locationManager requestWhenInUseAuthorization]; } CLCircularRegion *region = [[CLCircularRegion alloc] initWithCenter:CLLocationCoordinate2DMake(20, 20) radius:1000 identifier:@"asda"]; region.notifyOnEntry = YES;...

iOS: When I try to get CLLocation by click, there is most of the time a “big” lag

ios,objective-c,cllocationmanager
I'm first using the CoreLocation framework. I have a table and by button click a new location should be added and the distance to all entries in the table should be shown and updated all the time. That is why I have a BOOL saveNewLocation which is set to Yes...

Getlocation function not properly finding location

swift,cllocationmanager
My code is supposed to return the location of the device, for the purposes of placing a pin. For some reason when it is called multiple times, it always returns the value returned the first time it was called. The prints in the code are returning the first value. I...

CLAuthorizationStatus AuthorizedWhenInUse called only for the first time

swift,ios8,cllocationmanager
Here's a problem if I don't request "AuthorizedWhenInUse" status once my app first view controller is loaded I'll never get update after. Let's say I have a map view controller. When I ask for status in the viewDidLoad method it updates my location, i.e. func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!)...

Memory error implementing CLLocationManagerDelegate in a separate class

ios,swift,cllocationmanager
I try to move CLLocationManagerDelegate implementation to a separate class (file) in order not to clutter ViewController code but get memory error every time EXC_BAD_ACCESS (code=1, address=0xc) What am I doing wrong here? Here's my implementation: class ViewController: UIViewController { let locationManager = CLLocationManager() override func viewDidLoad() { super.viewDidLoad() locationManager.delegate...

CLLocation manager not returning location

ios,cllocationmanager
I am trying to get the current location using this code in my viewDidLoad method: //init the location manager locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBest; [locationManager startUpdatingLocation]; and I have my delegate methods: //if it fails to get the location - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error...

Find out if statUpdatingLocation is active in Swift

swift,cllocationmanager
I have a location based app running in swift. I am trying to detect if the self.locationManager.startUpdatingLocation() is currently active. I am struggling to find out how to do this nor can I find much on the internet about it. This I am fairly sure is rather simple to achieve....

iOS8 CLLocationManager returns Null in Background State

ios,ios8,cllocationmanager
in iOS8 when i m putting my app in back ground the CLLocationManager returns Null in location ,i have also unable Location updates in Background Modes and also do requestAlwaysAuthorization CLLocationManager *lm = [[CLLocationManager alloc] init]; lm.delegate = self; lm.desiredAccuracy = kCLLocationAccuracyBest; lm.distanceFilter = kCLDistanceFilterNone; [lm requestAlwaysAuthorization]; [lm startUpdatingLocation]; ...

how to pass longitude and latitude from CLLocationManager to use globally swift

swift,cllocationmanager,latitude-longitude
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) { var locValue:CLLocationCoordinate2D = manager.location.coordinate println("locations = \(locValue.latitude) \(locValue.longitude)") CLGeocoder().reverseGeocodeLocation(manager.location, completionHandler: {(placemarks, error)->Void in if (error != nil) { println("Error: " + error.localizedDescription) return } if placemarks.count > 0 { let pm = placemarks[0] as CLPlacemark self.locationManager.stopUpdatingLocation()...

CLLocationManagerDelegate delegate not called iOS in 8.1

ios,objective-c,location,static-libraries,cllocationmanager
I'm working with CLLocationManagerDelegate in my static library when i run on iOS 7 device everything works perfectly but when i test it on another device with iOS 8.1.3 the delegate methods aren't getting called. i made a strong property @property (nonatomic, strong) CLLocationManager locationManager i've also added the appropriate...

Invoking startMonitoringSignificantLocationChanges() shows the location services icon always on the status bar

ios,google-maps,swift,cllocationmanager
I'm invoking startMonitoringSignificantLocationChanges(), I have noticed this is making location services to run continuously which is making battery to consume more. Following is my piece of code, this is not complete code. class CurrentLocationController:UIViewController, GMSMapViewDelegate, CLLocationManagerDelegate { override func viewDidLoad() { super.viewDidLoad() let delegate = UIApplication.sharedApplication().delegate as AppDelegate locationManager =...

CLLocationManager ignores stopUpdatingLocation

ios,objective-c,swift,core-location,cllocationmanager
I am calling startUpdatingLocation() on a CLLocationManager, and in the didUpdateLocations method I am calling stopUpdatingLocation() when the accuracy is less than 100m like so: func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) { var lastLocation: CLLocation = locations.last! as! CLLocation var accuracy = lastLocation.horizontalAccuracy if (accuracy < 100) { locationCoordinate =...

Setting Parse PFGeopoints on a map only viewable for current user

parse.com,mkmapview,cllocationmanager
I have an array of PFGeopoints which I query from parses back end database, and I then annotate them points onto a MapView. I now a feature in my app where you can turn yourself off so nobody can see where you are, but the current user can still see...

Swift CLLocation does not update location at startup

ios,multithreading,swift,cllocationmanager
I have an application were I want to get the users location in viewDidLoad, I then store the lat and long in variables and use them in a function to get data based on the position from the user. I have a timer that calls a function every x minute...

App get in LocationManager approval loop

ios,cllocationmanager
In my app, I have the following code; - (void)applicationDidBecomeActive:(UIApplication *)application { // Start location services if ([self.locationManager respondsToSelector:@selector(requestAlwaysAuthorization)]) { [self.locationManager requestAlwaysAuthorization]; } locationManager = [[CLLocationManager alloc] init]; etc... Somehow, when I do a fresh install, as soon as the location manager is started, the app gets in a loop,...

Xcode 6 why CLLocationManager didn't return altitude and longitude

ios,iphone,cocoa-touch,cllocationmanager
Why I can get the direction but I can't get the altitude and longitude? Do I need to get user's location information admission,and write in my code? Here's my code #import "ViewController.h" @interface ViewController ()<CLLocationManagerDelegate> @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate =...

How to extend App wake-up time in ios

ios,cllocationmanager
I am using Location manager to wake-up my app when didExitRegion/didEnterRegion method called. App is waking-up but according to my test it will be awaken for 10 second. I want to extend this awaken time to 1 min, Is it possible? Please suggest....

CLLocationManager didVisit not working

ios,swift,core-location,cllocationmanager
I have created a class that handles some of the CoreLocation stuff and instantiated that in my AppDelegate, but I'm not receiving any didVisits as I drive around. What am I doing wrong? AppDelegate import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? let chauffeur = Chauffeur() func...

Battery drain issue while using iBeacons in iOS application

ios,objective-c,cllocationmanager,ibeacon
I am developing an iOS7+ application with iBeacon technology(Using estimote sdk 2.3.2). Now i am facing device battery drain issue while the app is running in foreground and background. Has any option for ranging iBeacons without using CLLocationManager?

Location manager accuracy not very accurate

ios,cllocationmanager
I am having an issue with sending location to other users. I using Parse.com as my backend and I use this code to get a location: -(void)sendLocation{ if ([locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]){ [locationManager requestWhenInUseAuthorization]; } [locationManager startUpdatingLocation]; } - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { [locationManager stopUpdatingLocation]; //kill it NOW or...

Alerting user that the app still uses Location Updates (GPS)

ios,ios8,gps,core-location,cllocationmanager
Some apps, including the apple maps or some navigation apps are alerting the user with a kind of blue alert stripe if you send the app to background, that the app still uses the GPS (LocationUpdates) Is there a public api or way to do this automatically or should it...

How to stop location tracking in app?

ios,cllocationmanager
I wrote a simple run tracking app. The location manager gets initialized when the user presses a start running button. But even after they press stop to stop location updates, ios continues to indicate thatnapp is using location tracking. How/what do I need to turn off apart from telling location...

GPS icon not disappearing when google maps api is being used in the app. iOS

ios,google-maps,gps,cllocationmanager
I am using google maps in my application and the problem is that even if i use stopUpdatingLocation and stopMonitoringSignificantLocationChanges, the GPS icon will not go away. I think it is because of google maps in the application. My Question is that how to remove GPS icon when using google...

CoreLocation Swift

ios,swift,cllocationmanager,cllocation
I've added the CoreLocation Library, along with NSLocationWhenInUseUsageDescription to info.plist but when I compile and run, it does not display the current location or prompt the user to allow access to current location. I currently have the following below, but it just displays the entire US. and The authorization status...

Add data to iBeacon Advertising Packet

ios,cllocationmanager,ibeacon
How can I add data (such as broadcasting its name) via iBeacon Advertising Packet? My current scenario: I have 3 transmitters and 1 receiver. But I can't differentiate among them, unless I turn on or off the transmitter one by one. How can I broadcast information to receiver? and how...

iOS 8 CLLocationManagerDelegate methods are never called

ios,iphone,cllocationmanager
//View did Load Method- LocationManager is allocated and have included the CLLocationManagerDelegate in .h File -ViewDidLoad{ self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; self.locationManager.desiredAccuracy=kCLLocationAccuracyBest; self.locationManager.distanceFilter=kCLDistanceFilterNone; [self.locationManager requestWhenInUseAuthorization]; [self.locationManager startMonitoringSignificantLocationChanges]; [self.locationManager startUpdatingLocation]; } // Location Manager...