FAQ Database Discussion Community


Reset settings on iPhone now device doesn't show in Xcode to run application

ios,iphone,xcode,ios-simulator,core-location
I was having an issue with Core Location in my app so I followed this advice (the selected answer) and reset my network and location settings on my device. Now that I've done that, my device isn't showing up as an option to build and run the app in the...

Change CLLocationDegrees into a Double/NSNumber to save in Core Data (Swift)

swift,core-location
In trying to change all my objective C code into Swift (which is a pretty steep learning curve in itself), I've hit a problem. I'm simply trying to save a CLLocationDegrees value into Core Data. But nothing I do is working. I started with: self.myLocation?.locationCurrentLat = self.fixedLocation?.coordinate.latitude But have no...

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...

NSLocation doesn't wait for me to click allow

ios,swift,core-location,cllocation
When I run the code, the window pops asking for permission to use location but disappears almost immediately, not giving the user a chance to click "Allow". Is there a way to force this action before proceeding? import UIKit import MapKit import CoreLocation class MapViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate{ var map:MKMapView?...

In Swift, can I detect if a CLLocation is valid or not?

ios,swift,mapkit,core-location
I am passing a location to another UIViewController which has a MapView using prepareForSegue. I call this receivedLocation. The map centers on the location that is passed. If the user clicks a button to take them to the map without first sending a location, won't this fail? How can I...

How can I build a route and access its coordinates?

swift,mapkit,core-location,watchkit
I'm writing an app on watchKit. My aim is to build a route between two points but I do not imagine how could I do it. On the iPhone MapKit does it for you, but can I do something similar in the watches? Can I access the route (array of...

How to override isEqual: for CLBeacon?

ios,objective-c,core-location,equality
Background I have a method, provided by a 3rd party library, that returns an array of CLBeacons. - (void)beaconManager:(ESTBeaconManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region This method is called at regular intervals and the array contains a list of the beacons that are in range. Objects in the array are not...

In Swift, how can I store the user's location inside a variable when I press a button?

ios,swift,core-location
In the main UIViewController, I want to store the coordinates of the user in a variable when they press a UIButton. This variable will be used in another UIViewController with a MapView. I tried setting up a locationManager(), but I could not get the button to work with it. Can...

Not required to import MapKit.framework?

ios,xcode,frameworks,mapkit,core-location
I'm making an app for my exam that uses theMapKitView andCoreLocation for getting different locations and adding pins to the map. But I realized that I hadn't imported the MapKit.framework in the build settings, which I always was told to do. What I don't understand is that everything still works...

Enable user to select location from drop down or map?

ios,iphone,swift,xcode6,core-location
I have an app that automatically gets the user's location via GPS if enabled, but I'd like to provide an option to allow the user to manually input the location. I'm not sure how this can work form a UX or technical perspective. Below is my screenshot from my table....

Core Location and UITableView performance issues in iOS 8

objective-c,uitableview,google-maps,ios8,core-location
I have a view controller that contains two views: a map view using the Google Maps API and a UITableView. The view controller fetches a list of location objects from Google Maps within a certain radius of a particular location and plots them on the map view as markers and...

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...

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...

Can't endBackgroundTask: no background task exists with identifier *, or it may have already been ended

ios,objective-c,core-location,uibackgroundtask
My app monitors user location updates (not necessarily significant location change) with: someLocationManager = [[CLLocationManager alloc] init]; [someLocationManager setDelegate:self]; [someLocationManager startUpdatingLocation]; When app (in simulator) is in foreground everything works ok, but when suspending it to background (not terminating), I get this error to the log: Can't endBackgroundTask: no background...

Location Services in iOS 8: Background Modes

ios,ios8,core-location
There is a Background mode called Location Updates. If I include the CoreLocation framework, and in my info.plist include the key NSLocationAlwaysUsageDescription and the value being a String with whatever I need to use it for, do I need to tick the background mode for Location Updates? Can I just...

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...

Updating app every 10 minutes within a beacon region

ios,core-location,core-bluetooth,ibeacon
iBeacon and iOS devices can update the app based on didEnterRegion and didExitRegion. How do I update the app when it's within the region. Let's say I want to update the app every 10 minutes the user is within region. Another thing is I find iOS's detection of iBeacon is...

Cannot get position from iOS simulator

ios,swift,core-location
I'm trying to get position by using iOS simulator by simple swift code. But In debugging session, callback function is not called. I set virtual position to iOS simulator. // ViewController.swift // helloWorld // // Created by on 5/17/15. // Copyright (c) 2015 All rights reserved. // import UIKit import...

Does a class being its own delegate follow iOS convention?

ios,objective-c,core-location
Sorry this question may sound "subjective" but I think it should have a pretty definitive answer. I have a class "LocationManager" that I want to manage my Core Location logic. I have two options: LocationManager has a strong property referencing an instance of CLLocationManager. LocationManager is a delegate of CLLocationManager...

iOS Swift - CoreLocation coordinates

ios,swift,core-location
I'm building an app that uses CoreLocation to get user's coordinates. After I start updating location, I'll get the coordinates in didUpdateLocations. Probably because of gps calibration, in didUpdateLocations I get 2 or 3 different coordinates, until it stops. How can I call a function after updating locations has stopped...

Core Location delegate methods not getting called in iOS 8.3 Xcode 6.3.1

core-location,ios8.3,xcode6.3.1
I am trying to get the user's current location using the Core Location Framework in Xcode 6.3.1, I did following things: Added Core Location Framework under Target-> General-> Linked Frameworks & Libraries My ViewController.h file is as shown below, #import <UIKit/UIKit.h> #import <CoreLocation/CoreLocation.h> @interface ViewController : UIViewController<CLLocationManagerDelegate> @property (weak, nonatomic)...

From where geocode server Apple API get its information

ios,iphone,swift,core-location
I'm working on backend of my iOS app. I need a list of all countries that CoreLocation might return. i.e If I was in U.S the returned county will be U.S or United State. I searched and find that CoreLocation used geocode API: Link but I didn't find from where...

NSLocationWhenInUsageDescription prompt doesn't pop up

ios,core-location
When I ran the app the NSLocationWhenInUsageDescription prompt came up once but never came up again after running it multiple times. The app is still zooming into the current location and the Apple location. The app works, but the question does not pop up....

IOS - Running background task for update user location using swift

ios,swift,core-location
i'm new user here, but I have used stackoverflow a lot of times :)... I'm android developer, but now i'm working in an ios app using swift. I'm totally new using xcode, maybe my question es very simple for a lot... Great, I really need help. I'm trying to implement...

Calculate Total Traveled Distance iOS Swift

ios,xcode,swift,core-location,cllocation
How can I calculate the total distance traveled use CoreLocation in Swift I haven't been able to so far find any resources for how to do this in Swift for iOS 8, How would you calculate the total distance moved since you began tracking your location? From what I've read...

Core Location not responding

ios,objective-c,location,core-location
When I enter the following code and run it on the simulator and set the location to "City Run", it does not log anything. I don't know what I am doing wrong though. .h #import <CoreLocation/CoreLocation.h> @interface ViewController : UIViewController <UITextFieldDelegate,CLLocationManagerDelegate> { CLLocationManager *locMgr; } @property (nonatomic, retain) CLLocationManager *locMgr;...

iBeacon monitoring and ranging in background

ios,core-location,ibeacon
I took several months developing an application based on iBeacons and I'm really frustrated. The general idea is that when a beacon is detected, the user is notified with information specific to that iBeacon. The application was designed as follows, all iBeacons have the same UUID, the Major determines the...

Having problems with iOS8 Core Location

ios,objective-c,ios8,core-location
Core Location usage change recently, but even after updating to the new specification I can't seem to get it working. I tried starting a new project with just a view controller that changes its background color upon GPS coordinate finding or failure. #import "ViewController.h" @interface ViewController (){ CLLocationManager *locationManager; }...

Trying to find users location in Xcode with Swift on starting the app but having optional error?

ios,xcode,swift,mapkit,core-location
I'm attempting to have the app find the user's location once the app has been started. However, I continually find an error in the viewDidLoad method as I try to requestWhenInUseAuthorization and I receive the following error: fatal error: unexpectedly found nil while unwrapping an Optional value (lldb) I would...

How to check if a user is at a specific region

swift,core-location
I'm wondering the easiest way to check and see if a user's current location is in range of a specific region. I have the region I want and I have the users current location all set up. I just need to know how to compare them. I tried using startMonitoringForRegion...

Swift: location not being updated when returned from background

swift,core-location
I have a Swift app that I am trying to update the location when the app is returned from the background, but it doesn't seem to work when returned from the background. On launch of the app, I'll get the location just fine. After getting the location I call stopUpdatingLocation()...

iOS search api for Maps

ios,mapkit,core-location
Is there a search api for apple maps? Like in apple maps, if you start typing an address, it filters the list with some possibilities. Is this available to developers? I saw that they added some MKLocalSearch in iOS 7, but i could not find anything that gives that capability....

Disabling UILocalNotifications after closing app

ios,background,core-location,ibeacon
I am using beacons in my app (app set to background) and I am setting series of UILocalNotifications on beacon:DidExitRegion: (kind of alarm when beacon is lost). Edit: When app is in the background, user exits region, then the notifications are set properly. When user wants to close the app...

calculate the speed in kilometer/hour using core location framework

ios,objective-c,core-location
I am calculating the distance and speed as below. totalDistance=totalDistance+[newLocation distanceFromLocation:self ->tempOldLocation]; distanceLabel.text= [NSString stringWithFormat:@"%.2f km", (totalDistance /1000)]; self->tempOldLocation=newLocation; Calculating Speed: CLLocationDistance distanceChange = [newLocation getDistanceFrom:oldLocation]; NSTimeInterval sinceLastUpdate = [newLocation.timestamp timeIntervalSinceDate:oldLocation.timestamp]; double calculatedSpeed = distanceChange / sinceLastUpdate; I want to calculate...

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...

iBeacon: stabilize signals

ios,core-location,core-bluetooth,ibeacon
Currently I have 3 transmitters and 1 receiver (4 devices are iPhones) setup allowing me to work on Trilateration. However, I found that the signals fluctuate a lot (even when 4 devices are put steady on tables). Is there any strategy to stabilize the signals? Should I calculate the average...

UILocalNotification Geofence: Ignore exiting region

ios,objective-c,core-location,uilocalnotification,geofencing
I want to use the new Geofence API of iOS 8 (scheduleLocalNotification:). I schedule a UILocalNotification with a region and so on. Everything works, but how can I differentiate between ENTERING and EXITING a region, resp. ignore EXITING? iOS always displays/sends a notification, but I only want a notification when...

iBeacon events while screen is off

ios,objective-c,core-location,ibeacon
I'm trying to trigger an event based on iBeacons It works fine when the app is running in the foreground, background but not suspended (screen is turned off with power-button) I can see the NSLog messages when on the lock screen, but not when the device screen is off. Is...

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 =...

didExitRegion not fired when turn off bluetooth

ios,objective-c,bluetooth,core-location,ibeacon
Im building a simple ios app with IBeacon, I'm monitoring a region but I have some issues with enter and exit events. If I go into a region the callback didEnterRegion is fired, but being within the region, turning off bluetooth doesn't fire didExitRegion callback. Is this the expected behavior?...

What is the proper way to search for regions in CoreLocation with Swift?

ios,swift,xcode6,bluetooth-lowenergy,core-location
I've been working with a number of tutorials and continuously have the exact same issue with each of them. When I run the following code or other incarnations of it in other tutorials, I keep getting: 2015-06-12 13:50:33.797 Scanner[4599:2593734] *** Assertion failure in -[CLLocationManager startRangingBeaconsInRegion:], /SourceCache/CoreLocationFramework/CoreLocation-1756.0.20/Framework/CoreLocation/CLLocationManager.m:1129 2015-06-12 13:50:33.798 Scanner[4599:2593734] ***...

CLLocationManager doesn't start location updates when application did enter background

ios,objective-c,cocoa-touch,core-location
In my app I need to perform location updates in background. For this purpose I registered my location tracking object as observer like this: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(start) name:UIApplicationDidEnterBackgroundNotification object:nil]; and this is the method that starts updating location: - (void)start { NSInteger downloadsCount = [[SGDataManager sharedInstance] countOfActiveDownloads]; NSInteger uploadsCount...

Is it possible to fallback to AuthorizedWhenInUse when a user doesn't allow AuthorizedAlways in iOS?

ios,permissions,gps,core-location
My app uses user location in the background, but sometimes, users don't allow the app to always collect GPS data. The app can handle foreground only locations, and I'd like to set that as a fallback. Is there a graceful way, once an iOS user has declined my AuthorizedAlways request,...

Unable to get longitude and latitude in ios8 by GPS

ios,ios8,gps,location,core-location
I am using iOS8 and using the following code for getting longitude and latitude by GPS: -(void)CurrentLocationIdentifier { locationManager = [CLLocationManager new]; locationManager.delegate = self; locationManager.distanceFilter = kCLDistanceFilterNone; locationManager.desiredAccuracy = kCLLocationAccuracyBest; if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0 && [CLLocationManager authorizationStatus] != kCLAuthorizationStatusAuthorizedWhenInUse) //[CLLocationManager authorizationStatus] !=...

iOS7 and iOS 8 location services

ios,objective-c,core-location
I have an app and I want to add some location based features to it. It supports both iOS 7 and 8, but I'm having some issues. I want to request the permission for location only when the user taps a certain button on a certain viewController. The issue is...

Going from “While using the app” to “Always” and viceversa from code

ios,objective-c,core-location
Is it possible to change the users settings from "While using the app" to "Always" location type, and viceversa? Obviously, once the user has accepted to share both types of locations. I don't want to make the user go open the settings and change it, if he has already allowed...

How to detect system wide Location Services changes

ios,ios8,core-location
I'm going through potential cases where a User might turn off Location Services on their phone. Right now, I have: func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) { if status == .Authorized || status == .AuthorizedWhenInUse { manager.startUpdatingLocation() } else { manager.stopUpdatingLocation() } } I assume this will trigger whenever the...

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...

CLLocationManager didUpdateLocations not being called iOS 8 with plist entries

ios,swift,core-location
I'm having some issues with CLLocationManager. This code used to work on iOS 8.2 but since upgrading to 8.3 it doesn't work. Here is the code for setting up the location manager which is called on startup. let distanceThreshold:CLLocationDistance = 100.0 var currentLocation:CLLocationCoordinate2D? override init() { assert(locMan == nil) super.init()...

CLLocationManager doesn't show popup if location services were previously disabled

ios,objective-c,cocoa-touch,core-location
When I launch my app I check current location authorisation status like this: - (void)checkCurrentStatus { if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined) { [self.locationManager requestWhenInUseAuthorization]; } else if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied && ![CLLocationManager locationServicesEnabled]) { [self.locationManager startUpdatingLocation]; } } If overall location services are enabled (for the whole device) than...

Does desiredAccuracy affect region monitoring?

ios,iphone,core-location,geofencing
Does DesiredAccuracy property affect region monitoring ? My guess is that it just affects location updates, but I want to be sure. Apple documentation doesn't specifically say anything about that.

iOS not requesting location services when request code executes

ios,objective-c,cocoa-touch,core-location
I have a weird bug happening in an iOS app I am developing (Objective C). I am using location services inside an object that is created and stored as an instance variable of the root view controller class. This object is initialized in the viewDidLoad method. if (sunEventObject == nil)...

Location accuracy defined - iOS

ios,gps,core-location
What is the statistical intention, even if an approximation, of the returned "accuracy" or "uncertainty" on iOS? For instance Android documentation gives an interpretation of its returned accuracy figure as being approximately one standard deviation in this sense: We define accuracy as the radius of 68% confidence. In other words,...

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...

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...

Why is CoreLocation (Mac OS X) not remembering my choice to allow its use?

osx,cocoa,core-location
I'm probably being very stupid, but I can't work out why the following is happening: I have an app on Mac OS X which uses CoreLocation. Below is the the relevant code: It asks for permission to use my location every time it launches and never remembers that I have...