Core Location

RSS for tag

Obtain the geographic location and orientation of a device using Core Location.

Core Location Documentation

Posts under Core Location tag

165 Posts
Sort by:
Post marked as solved
10 Replies
11k Views
Hi everyone,I want to ask and to better understand about the popup that iOS will occasionnally ask the user like :"Weather" has been using your location in the background. Do you want to continue allowing this ?How often dose this occur nad how do they determine when to ask ? And is it possible to prevent this to show to the user ?I can't find any documentation, the only explanation i can find is from the presentation from WWDC 2014 video "What's New in Core Location".Thank,Pat.
Posted
by
Post not yet marked as solved
2 Replies
1.5k Views
Hello. I got another question.I need to draw half-circle on MKMapView knowing the center coordinates, start and end angles, and radius in nautical miles.I have subclassed MKOverlayPathRenderer:import UIKit import MapKit class IGAAcarsDrawArc: MKOverlayPathRenderer { let PI = 3.14159265 let radius : CGFloat = 10.0 var startAngle: CGFloat = 0 var endAngle: CGFloat = 3.14159 var latitude = 25.96728611 var longitude = -80.453019440000006 override func createPath() { let line = MKPolyline() let arcWidth: CGFloat = 5 let path = UIBezierPath(arcCenter: CGPointMake(CGFloat(latitude), CGFloat(longitude)), radius: self.radius, startAngle: startAngle, endAngle: endAngle, clockwise: true) path.lineWidth = arcWidth path.stroke() } }Now, it is not clear how do I use this to create MKPolyline and implement in mapView(mapView: MKMapView, rendererForOverlay overlay: MKOverlay). Does anyone know how to draw an arc in MKMapView?Thanks a lot!
Posted
by
Post not yet marked as solved
1 Replies
1k Views
If I have a mapview with a tileoverlay and polyline, the view works until I zoom in close. When zoomed in, the tiles under the polyline don't render, but other tiles not under the polyline do. Xcode 7.3.1 targeting ios 9.3.Below is the minimal test case I have come up with to show this. Any ideas how to debug further? If I remove the polyline overlay, zoom works perfectly fine for all tiles. class MyController: UIViewController, MKMapViewDelegate { @IBOutlet weak var mapView: MKMapView! var overlay:MKTileOverlay = MKTileOverlay(URLTemplate: "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}.jpg"); override func viewDidLoad() { mapView.delegate = self mapView.showsUserLocation = true; overlay.maximumZ = 15; overlay.minimumZ = 12; overlay.canReplaceMapContent = true mapView.addOverlay(overlay); var points: [CLLocationCoordinate2D] = [CLLocationCoordinate2D]() points.append(CLLocationCoordinate2D(latitude: 40.7608, longitude: -111.8910)); points.append(CLLocationCoordinate2D(latitude: 40.8894, longitude: -111.8808)); var polyline = MKPolyline(coordinates: &points, count: points.count) mapView.addOverlay(polyline) let region = MKCoordinateRegion(center: points[0], span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05)) mapView.setRegion(region, animated: false) } func mapView(mapView: MKMapView!, rendererForOverlay overlay: MKOverlay!) -> MKOverlayRenderer! { if overlay is MKPolyline { var polylineRenderer = MKPolylineRenderer(overlay: overlay) polylineRenderer.strokeColor = UIColor.blueColor() polylineRenderer.lineWidth = 5 return polylineRenderer } else if (overlay is MKTileOverlay) { let renderr = MKTileOverlayRenderer(overlay: overlay) return renderr } return nil } }
Posted
by
Post not yet marked as solved
2 Replies
3.1k Views
Hello everyone. I need a clarification with Core Location, please help.How exactly is GPS data passed from external GPS source that is connected via Bluetooth? After some googling I found two separate points:Core Location (CLLocationManager) is responsible only for internal GPS receiver data. For external BT sources I need to use EAAccessory and read NMEA protocol.When I connect an external source, internal GPS is switched off instantly and CLLocationManager starts providing its data. So it must work OK.Thing is, I don't have an external source to test it and I'm not that experienced in BT.I have a report that people cannot use external GPS source with my app (I use Core Location only). Though I also have an info that all navigation apps support external GPS source. So they've already solved this?Or maybe I should check Core Bluetooth out for this?My question is kind of close to this one:https://forums.developer.apple.com/thread/69717?q=gpsMaybe MFi really has a relation to that? And something can depend on GPS device being MFi or being not MFi?Or this one:https://forums.developer.apple.com/message/31679#31679Seems much closer to my topic. So if I got it right, all MFi-supported external GPS data sources should work as is via Core Location?If that's true, is all CLLocation data valid there (when using external source)? Or just altitude and position?
Posted
by
Post not yet marked as solved
5 Replies
6.5k Views
This is my snippet code:if (([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) { NSURL *URL = [NSURL URLWithString:@"App-prefs:root=Privacy&path=LOCATION"]; [[UIApplication sharedApplication] openURL:URL options:@{} completionHandler:nil]; }This code works fine for iOS 10.0 to 10.3.3 but when I run this code for iOS 11(beta), the application goes into the background but the Setting page doesn't get opened.
Posted
by
Post not yet marked as solved
6 Replies
4.8k Views
Hi!I noticed a strange behavior on MapKit when using the iOS 11 clustering feature.If you add some annotations on a map (with same clusteringIdentifier and same displayPriority) MapKit will correctly merge together annotations that are close.The problem is that if you remove all the annotations and then you add them back the map will no more merge the annotation together. It’s like the clustering feature simply stop working.I don’t really know if it is a bug or if I miss something.Someone else have noticed this?Alan
Posted
by
Post not yet marked as solved
1 Replies
864 Views
Hi,I've got annotations on a MKMapView and I added a custom view inside the detailCalloutAccessoryView. This custom view performs a request and should present various amount of data depending on the request's reply. Basically, I can show 1 or 2 rows of data.Sometimes, when I touch an annotation and the result is only one row, the callout is not resized. However, if I dimiss the annotation and select it once again, it is rendered correctly.What is the "right" way to make it work? Using a intrinsicContentSize, or calling layoutIfNeeded (already tried, did not work)Thanks for your help.
Posted
by
Post marked as solved
4 Replies
2k Views
As far as I can tell in my app I am requesting current location in the app and in the widget the same, but I am not ever seeing my widget make the network call the I would expect if current location was successful. I have the same info plist permissions for usage and request for access in both the app and the widget ( runs the same shared code ). My question is does widgetKit work to get core location similar to the the way that today extensions work. or do I need to cache it from the phone app and hope its been updated ?
Posted
by
Post not yet marked as solved
13 Replies
18k Views
Whenever I fresh install my app onto my device, it is not showing up in the Settings app. Even after trying to search it, nothing appears. I use location services and local network within my application so I need to be able to change those authorizations as it does not reliably prompt for those authorizations (I need always for location and that was removed, local network never prompts correctly). I have however seen my app appear in the settings app under privacy -> Location Services but not local network. Is this an issue with Apple or with my application? Should also be known that it does appear in settings on some devices.
Posted
by
Post not yet marked as solved
2 Replies
1.1k Views
Hi, The ARkit is a great tool, I have my small app doing things, and it's fun! but I wanted to try to migrate from ARWorldConfiguration to ARGeoTrackingConfiguration - https://developer.apple.com/documentation/arkit/argeotrackingconfiguration and then we can see that this configuration is limited to a couples of USA only cites. But I can't manage to figure Why and if, in the near future, this will be expanded world wide ?
Posted
by
Post marked as solved
11 Replies
2.7k Views
I just submitted a feedback for this (FB9662125) but in the spirit of “share and enjoy”… The cool new Generate Info.plist File feature in Xcode 13 crashes if you try to put an NSLocationTemporaryUsageDescriptionDictionary in your Info.plist file. Here’s a simple repro scenario: Create a minimal iOS app (no Core Data, no tests) Go to target settings → Info tab → Custom iOS Target Properties Click the (+) button on any row to begin inserting a new row Select Privacy - Location Temporary Usage Description Dictionary Click somewhere else or press Return to commit the selection Xcode crashes immediately More generally, it seems that Xcode crashes any time it tries to regenerate your Info.plist file if it contains an NSLocationTemporaryUsageDescriptionDictionary, even if (for example) you manually pasted that dictionary into the file earlier. In that case, merely tapping the (+) button in step 3 above is enough to crash it.
Posted
by
Post marked as solved
11 Replies
14k Views
When I run an app that uses location services on the Xcode 13.1 simulator for iOS 15 the location privacy settings are missing. If you go to the settings on the simulator under privacy the section for location services is missing. The exact same thing on a physical iPhone running iOS 15.0 does show the location settings under privacy in the settings app. Where did the settings for location privacy go? In order to test using the simulator a developer needs to be able to turn those settings on and off, like turning off precise location to see how an app responds.
Posted
by
Post not yet marked as solved
3 Replies
2.9k Views
Hi guys, I have built a PWA that calls the javascript API navigator.geolocation.getCurrentPosition which prompts the user for location access when the Safari permission is set to Ask. This is the correct behavior and works as expected when open in Safari. However when added to the Home Screen and running with a display mode of "standalone", the location alert does not open on my phone (iPhone 13 mini / iOS 15.1.1). And the call never times out. Then if I switch from the PWA to Safari the location alert / prompt is suddenly showing in Safari. So it seems that the alert is targeting the wrong "tab". This does not happen if the PWA display mode is "browser" or "mimimal-ui" with either of those it behaves normally. I can only replicate this on my phone (iPhone 13 mini / iOS 15.1.1). I have also tested on various older phones (15.1.1 and 14.7) as well as several emulators and they all behave as expected. It is possible this is a obscure setting on my phone but it does feel a lot like an iOS Safari bug.
Posted
by
Post not yet marked as solved
0 Replies
1.7k Views
I am building an iOS app that uses the phone's GPS EXIF data from both camera and image library. My problem is that I while I am able to get GPS data from images in the phone's library, I have not been able to get any GPS data when using the camera within my app. I first built this app about a year ago and at that time I was able to get GPS data from both the library AND the camera from within the app. I believe that at that point I was still building for iOS 12.. I believe that the new security features that came with iOS 13 or 14 now dissalow my app's access to the GPS data when using the camera. This issue is new as of iOS 13 or 14. The code I had was working fine with earlier versions of iOS I am having no issues with getting GPS from the EXIF on the device library images. Images taken with the NATIVE IOS CAMERA APP are saved to the library with full GPS data.  - However I am not able to get GPS data directly from camera image EXIF when using the camera from within my app. When saving an image taking by the camera from within my app the image is saved to the library with NO GPS data. I am able, at any time, to ask the device for current GPS coordinates. As far as I can tell, device settings are all correct. Location services are available at all times.  My feeling is that iOS is stripping the GPS data from the EXIF image before handing the image data to my app. I have searched Apple developer forums, Apple documention, Stack Exchange, on and on for over several weeks now and I seem no closer to knowing if the camera API even returns this data or not and if it will be necessary for me to talk to the location services and add the GPS data myself (which is what I am working on now as I have about given up on getting it from the camera). Info.plist keys I am currently setting:  LSRequiresIPhoneOS  NSCameraUsageDescription  NSLocationAlwaysUsageDescription  NSLocationWhenInUseUsageDescription  NSMicrophoneUsageDescription  NSPhotoLibraryUsageDescription  NSPhotoLibraryAddUsageDescription Am I missing some required plist key? I have been searching and searching for the name of a key that I might be missing but have found absolutely nothing other than people trying to hack some post-camera device location merging. This has been very frustrating.. Any insite is appreciated Is it currently possible to get GPS data directly from the camera's EXIF output any more? Do I need to ask the device for the current GPS values and insert the GPS data into the image EXIF on my own? Is there any example code of getting GPS data from the camera? Is there any example code of inserting GPS data into the Exif before saving the file to the device? Sample swift code which processes the camera image.   func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {     let pickedImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage     // let pickedImage = info[UIImagePickerController.InfoKey.editedImage] as? UIImage     // using editedImage vs originalImage has no effect on the availabilty of the GPS data     userImage.image = pickedImage     picker.dismiss(animated: true, completion: nil)   }
Posted
by
Post not yet marked as solved
6 Replies
2.9k Views
I have given location permission for the app i'm developing. Now i need to reset location permission and want to see the permission pop-up. I have tried tccutil reset and /var/db/locationd/clients.plist is not accessible. Both are failing even with sudo. Please suggest any methods.
Posted
by
Post not yet marked as solved
10 Replies
10k Views
In our latest two pushes to AppStore Connect, we've been getting the following message, where we hadn't previously: Dear Developer, We identified one or more issues with a recent delivery for your app, "XYZ" 1.2.3 (123). Your delivery was successful, but you may wish to correct the following issues in your next delivery:  ITMS-90683: Missing purpose string in Info.plist - Your app’s code references one or more APIs that access sensitive user data, or the app has one or more entitlements that permit such access. The Info.plist file for the “xyz.app” bundle should contain a NSLocationAlwaysAndWhenInUseUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. If you’re using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. Oddly though, we've not really made any changes to our codebase that should trigger this. Just wondering if others are seeing the same message? Has the algorithm to detect this changed recently and giving false positives? We've even uploaded a previous release (that didn't get this warning) to check if we get the warning again, and we are receiving the warning on an app upload that didn't get the warning previously. Would be good to know if any logic behind this trigger has changed, or is anyone else getting the same message when they are not expecting it? Searching our Codebase for CoreLocation reveals nothing, is there anything else that may trigger this popup and require this plist key?
Posted
by
Post not yet marked as solved
1 Replies
995 Views
Hello guys, I have an Electron app build with electron forge (v6.0.4). I was able to pass the verification via Transporter and able to install it from TestFilght. but the app was not able to run. I have tried to run the app from Terminal, I got the following error message: FATAL:mach_port_rendezvous.cc(142)] Check failed: kr == KERN_SUCCESS. bootstrap_check_in com.xxxx.yyyyy.MachPortRendezvousServer.39844: Permission denied (1100) Then I looked into the system logs, I found: 2022-12-17 22:03:10.473560 (gui/501 [100006]) : denied lookup: name = com.apple.CoreLocation.agent, flags = 0x1, requestor = AppName[39844], error = 159: Sandbox restriction 2022-12-17 22:03:10.473654 (system) : denied lookup: name = com.apple.locationd.desktop.registration, flags = 0x8, requestor = AppName[39844], error = 159: Sandbox restriction 2022-12-17 22:03:10.482191 (system) : failed lookup: name = com.epsecurity.bdconnectorservice, requestor = BDCoreIssues[162], error = 3: No such process 2022-12-17 22:03:10.537167 (gui/501/com.apple.xpc.launchd.unmanaged.AppName.39844 [39844]) : added unmanaged active 2022-12-17 22:03:10.537647 (gui/501 [100006]) : failed activation: name = com.xxxx.yyyy.MachPortRendezvousServer.39844, flags = 0x1, requestor = AppName[39844], error = 1: Operation not permitted I have tried with/without com.apple.security.personal-information.location in my entitlements file, but looks like no difference. I have spent many days on it, anyone can help?
Posted
by
Post not yet marked as solved
4 Replies
2.1k Views
Hi, I am trying to find out the GPS/Location update rate that the iPhone14 can accomplish. Most GPS update rates are 1hz (1 location update per second). I am hoping that the newest iPhones can provide a faster update rate. Also I would like to know the accuracy of the GPS. It is 100meter, 50meter, 10meter, 3meter? Where could I find this information? Thanks, Adam
Posted
by
Post marked as Apple Recommended
9.3k Views
Our app gets background location updates and has been working well right up to, and including iOS 16.3.1. However, testing with iOS 16.4 we are finding that background location updates stop shortly after they start. I have spoken with other developers and they’re noticing the same thing. Anyone else using background location updates finding this to be a problem?
Posted
by