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 not yet marked as solved
0 Replies
612 Views
There are several threads on the forum in which the developers claim that background geolocation does not work. https://developer.apple.com/forums/thread/726945 https://developer.apple.com/forums/thread/727015 Gualtier Malde suggested a solution The issue that is described here due to the changes with iOS 16.4 (and above) which affect the behavior of apps tracking location in the background. Beginning in iOS 16.4, apps calling both startUpdatingLocation() AND startMonitoringSignificantLocationChanges() may get suspended in the background if they are specifying low accuracy and distance filtering in the location manager settings. If your app needs only low accuracy locations of kCLLocationAccuracyKilometer and up, use startMonitoringSignificantLocationChanges() for that purpose instead. If your app requires continuous high accuracy locations in the background, you must set the following location manager properties: allowsBackgroundLocationUpdates must be set to TRUE or YES distanceFilter must not be set, or set to kCLDistanceFilterNone desiredAccuracy must be kCLLocationAccuracyHundredMeters or better. If you’re using numeric values, it must be set to less than 1000 meters Alternatively you can turn on the location indicator which will avoid the issue. You can do this by setting showsBackgroundLocationIndicator to TRUE or YES If you implement the above changes in your app, its location update behavior will be similar to behavior prior to iOS 16.4. Without these changes, your app may not be able to receive continuous background location updates. But this solution doesn't help. According to our data, the number of users with the problem is continuously increasing. The problem is confirmed on iOS versions up to 16.6 Beta Please, help 🥹
Posted
by
Post not yet marked as solved
1 Replies
548 Views
What is the minimum horizontal accuracy value that we can expect in a location callback? Because I want to know if it is possible to get a horizontal accuracy <= 5
Posted
by
Post not yet marked as solved
0 Replies
242 Views
Hi, We wanted to address some issues we are facing with the Go RN application, a healthcare staffing app that utilizes location tracking. Our application is designed to track the user's location during their work hours to provide important information to supervisors in the healthcare industry. Specifically, we need to know if the user has left the work site. To achieve this, we have implemented a geofencing feature that tracks the user's location continuously, even when the app is running in the background. However, once the user's shift ends, we no longer require or track their location in the background. This location tracking feature offers benefits such as providing directions to the user's next shift location (since one shift may have multiple locations) and enabling auto check-in once they are in adequate proximity to the facility. Currently, our iOS application encounters a problem where background location fetching automatically stops after the user logs in for their shift using the mobile app and puts the app in the background, resulting in a false breach. Upon investigating the code, we have identified an inconsistency in the working of the geofencing functionality involving CLLocationManager functions. We are currently using region monitoring and significant location change. While the didEnter and didExit functions work as expected upon user entry and exit, the didUpdate function is not consistently functioning correctly. This issue arises particularly when the app goes into the background state or when users lock their screens. We have already enabled background location and background processing, along with relevant settings, to ensure seamless operation. In addition to addressing this issue, I wanted to inquire if there are alternative methods, aside from didUpdate, that can reliably determine whether a user is intentionally bypassing the geofence by disabling their location or network. Currently, we are checking the user's proximity to the intended location every 5 minutes to ensure that the user remains active and that both location and GPS functionalities are enabled. Any advice or guidance on how to ensure the consistent and reliable functioning of the didUpdate function under all circumstances would be highly appreciated. Additional Details https://docs.google.com/document/d/1aVI_kuy0KcQMdeX-52afG3HoJJ8YEQtcTGCifsy34Eg/edit We believe that having a further discussion on a call would be beneficial. Please let us know if this is possible. Thank you for your attention to this matter.
Posted
by
Post not yet marked as solved
0 Replies
581 Views
I'm trying to make an iOS (SwiftUI based) app to connect the arduino and send the current latitude value of ios to arduino. I successfully made the view that allow user to select the bluetooth device, and the UUID/name of the device is successfully displayed. Also, the arduino device detects connection (I used LiquidCrystal to display serial and it says "OK+CONN" and "OK+LOST" if connection was lost.), but when I click "fetch location" button, nothing happens on arduino side. The code is in stackoverflow due to character limits: https://stackoverflow.com/questions/76752529/arduino-hm-10-bluetooth-with-ios-connected-but-it-doesnt-send-values
Posted
by
Post not yet marked as solved
0 Replies
376 Views
when requestWhenInUseAuthorization() some phone not show system prompt view,The NSLocationWhenInUseUsageDescription key is already add. -locationManager:didChangeAuthorizationStatus: callback too kCLAuthorizationStatusNotDetermined,but the iPhone not show use location dialog,Does anyone know the reason?
Posted
by
Post not yet marked as solved
0 Replies
248 Views
Error Domain=CLLocationPushServiceErrorDomain Code=3 "(null)" An error occurs when calling startMonitoringLocationPushes(completion:). Why does this error occur? Included com.apple.developer.location.push entrymen when I generated the bundle ID. Added push notification functionality. Requested Location service permission. Added location push service extension target.
Posted
by
Post not yet marked as solved
0 Replies
638 Views
I'm using Xcode 14.3.1 I’m working on a macOS app that needs reverse geolocation. I have the following code: let thisLocation = CLLocation(latitude: lat, longitude: long) let geocoder = CLGeocoder() geocoder.reverseGeocodeLocation(thisLocation, completionHandler: { placeMarks, error in myLocality = (placeMarks?.first?.locality ?? "") + ", " + (placeMarks?.first?.administrativeArea ?? "") }) The geocoder.reverseGeocodeLocation call gets flagged with: Consider using asynchronous alternative function First off, it is async. myLocality doesn’t get filled in until long after the call has been issued. The use of a completitionHandler guarantees that. I tried an alternative geocoder.reverseGeocodeLocation call that really claims to be async, https://developer.apple.com/documentation/corelocation/clgeocoder/1423621-reversegeocodelocation. (This same page claims the call above is synchronous but with a completion handler. To me that’s an oxymoron, a completion handle by definition is not synchronous, https://developer.apple.com/documentation/swift/calling-objective-c-apis-asynchronously) Replacement code: let thisLocation = CLLocation(latitude: lat, longitude: long) let geocoder = CLGeocoder() let locationSemaphore = DispatchSemaphore(value: 0) Task { do { let placemark = try await geocoder.reverseGeocodeLocation(thisLocation) myLocality = (placemark.first?.locality ?? "") + ", " + (placemark.first?.administrativeArea ?? "") } catch { print(“Unable to Find Address for Location " + String(lat) + "," + String(long)) } locationSemaphore.signal() } // Task locationSemaphore.wait() In this second case, the semaphore.wait() call gets flagged the message: Instance method 'wait' is unavailable from asynchronous contexts; Await a Task handle instead; this is an error in Swift 6 Speaking from testing, the wait simply never gets resolved. I will add that my reverseGeocodeLocation call is nested in another async call. I guarantee that this is my max depth of 2. My semaphore logic works elsewhere in the code creating the first async call. My main question is how can I get the reverseGeocodeLocation synchronously, before moving on? How can I get a Task handle to wait on? Thanks all.
Posted
by
Post not yet marked as solved
0 Replies
429 Views
I have my own iOS app that works great. But I needed to connect Location Push Service Extension to this application. The steps I performed: I got the entitlement for location push type, created certificates, profiles for this service, then I implemented this service by connecting all profiles to it and adding to .entitlements com.apple.developer.location.push. In the AppDelegate of my application, I create a service that has a CLLocationManager in it, which monitors the departure of the application to the background and immediately calls the startMonitoringLocationPushes method. startMonitoringLocationPushes works fine and gives me APN token. But when I try to send a notification to the device, the service is not even called. The push structure looks like this: payload: {}, compiled: false, aps: {}, expiry: -1, priority: 10, topic: 'ru.profsoft.alertonDev.location-query', pushType: 'location' } [headers] { 'apns-topic': '<MainAppID>.location-query', 'apns-push-type': 'location' } I use a small service on Node JS to send push notification to APN and it successfully delivers them, and the Apple console also successfully delivers them But when device is successfully gets any location push, service is not calling. I started to use Debug -> Attach to process by PID or Name and got this error: Thread 1: EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=24 MB) But my LocationPushService contains only autogenerated code without any extra implementation. Also I checked Console and found these errors when I delivered push to the device: This is first error's description: Failed to get LSApplicationRecord for <RBSLaunchRequest| xpcservice<ru.profsoft.alertonDev.AlertonLocationPushServiceDev([osservice<com.apple.locationpushd>:201])>; "Launching extension ru.profsoft.alertonDev.AlertonLocationPushServiceDev(BB972E40-8E19-48D5-B05D-13A5D9D7005B) for host 201"> with error Error Domain=NSOSStatusErrorDomain Code=-10814 "(null)" UserInfo={_LSLine=1538, _LSFunction=runEvaluator} Can anybody help with this?
Posted
by
Post not yet marked as solved
1 Replies
636 Views
Hello, I am building an enterprise application, where I will be syncing user location to the backend server every 5 min for a period of 12 hr every day. I have enabled location updates and background processing for the app in Xcode, and also will be getting location permission as always from user. We are able to get the location update from the user for the whole time, but the part where we make the service call to sync with backend is delayed. It works fine for the first couple of minutes, but later we see the delay. I have also used NWConnection to directly make the service call without using URLSession, this approach is slight better comparatively, but not perfect. I have made sure "Low power mode" and "Low data mode" is disabled, also "Background App Refresh" is enabled for the application. I believe it should be possible since may app eg. WhatsApp, Telegram have a feature of sharing live location for up to 8 hrs. Is there any way where we can achieve this without delay? Thanks in advance.
Posted
by
Post not yet marked as solved
2 Replies
1.2k Views
I am seeing location permission settings "going away" after upgrading to 17b2. In my app settings it looks like this: Before upgrade: after upgrade: And when I launch my app, it detects that location is not set to Always and prompts me to fix it (expected behavior). Is anybody else seeing this kind of behavior?
Posted
by
Post not yet marked as solved
5 Replies
1.7k Views
Hello folks, I have been observing a strange behaviour on my Apple Watch Ultra. Device Environment: Apple Watch Ultra on WatchOS 10 Beta Offline Disconnected from companion iPhone Workout active: "Walking" Expected behaviour: The workout should record accurate locations (with accuracy of approximately 3-4 meters). This level of accuracy is already being achieved in the same watch (verified using several GPS status apps) when a workout is not active. . Observed behaviour: Accuracy as good as 2 meter is observed when no workouts are active, but as soon as the workout starts, the accuracy drops to a maximum of 14 meters and never gets better than this. This is confirmed to be happening every single time and is verified using several GPS status apps during the workout. Does anyone else has faced similar behaviour?
Posted
by
Post not yet marked as solved
1 Replies
430 Views
Hello. I am trying to create an app that detects the beacon and makes a BLE connection when the beacon is turned on while the iPhone is in sleep mode, without the app being on the app switcher. However, there are often times when beacons cannot be detected or BLE connections cannot be made. From what I've found, it's because iOS limits beacon/BLE scanning for security reasons. I know it's impossible, but is there any way to remove this restriction on scanning? If you can't, we would like to know when iOS places restrictions on scanning. If you can't, then we would like to know when iOS places restrictions on scanning and when those restrictions are lifted. Thank you very much. Development Environment: iPhone8 (iOS 13.7), iPhone13(iOS 16.0.3), macOS Monterey, MacBook Pro 2020(Intel Core i5), Xcode 14.2
Posted
by
Post not yet marked as solved
1 Replies
515 Views
We are currently experiencing a very interesting issue when accessing the location in the background with CLLocationManager. The user has given our app the "whenInUse" permission for locations and in most cases the app provides location updates even when it's in the background. However, when we started to use other navigation apps in the foreground we saw that the func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) method was called with (kCLErrorDomain error 1.). The user hasn't changed the location permission and we saw that locations were delivered once the user opened the app again. I don't see anything in the documentation explaining this issue, but I chatted with other developers that confirm that specific behavior. Am I missing something here?
Posted
by
Post not yet marked as solved
0 Replies
404 Views
Hello all! Apple presented the all-new Core Location Monitor at WWDC 2023. It changes the logic of monitoring for iBeacons with a new approach of adding CLCondition-s for monitoring iBeacon values like UUID, major, and minor. This, I suppose (please do feel free to correct me) is meant to replace current (now deprecated) startMonitoring implementation. Now, we it's a fact that it is impossible to monitor more than 20 regions at once. Question: does the new CLMonitor let us bypass this limit? If not, what's the maximum number of CLConditions we can add to a CLMonitor?
Posted
by
Post not yet marked as solved
1 Replies
398 Views
Hello all, I want to ask is CLGeocoder free or we needs pay more if reach the limit 25,000 calls daily? if needs to pay, is there any information about the pricing list? Thank you,.. Have a nice day.
Posted
by
Post not yet marked as solved
0 Replies
273 Views
Hi all, I have created an application that uses location services and bluetooth services. Inside AppDelegate using significant location changes I am assigning a new instance of CBCentralManager like this How long this instance is staying alive? I am noticing that it may last even five days but I am not sure which parameters affect this? class AppDelegate: UIResponder, UIApplicationDelegate ,CLLocationManagerDelegate,CBCentralManagerDelegate,UNUserNotificationCenterDelegate { private static var centralManager : CBCentralManager! func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { if let keys = launchOptions?.keys { if keys.contains(.location) { AppDelegate.centralManager = CBCentralManager(delegate: self, queue: nil) locationManager.requestAlwaysAuthorization() locationManager.allowsBackgroundLocationUpdates = true locationManager.pausesLocationUpdatesAutomatically = false } } return true } func centralManager(_ central: CBCentralManager, didDiscover peripheral:CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { AppDelegate.centralManager.connect(peripheral, options: nil)* } func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) { AppDelegate.centralManager.connect(peripheral, options: nil) } func centralManager(_ central: CBCentralManager, didDisconnectPeripheral peripheral: CBPeripheral, error: Error?) { AppDelegate.centralManager.connect(peripheral, options: nil) } }
Posted
by
Post not yet marked as solved
9 Replies
1.3k Views
I am testing my app on watchOS 10 though, After installing the app once on the Apple Watch and getting location permissions with CLLocationManager, Uninstall the app and install it again, When I check from Privacy in the Settings app on my Apple Watch, location is still allowed, but location information is no longer available. Does anyone know how to fix this?
Posted
by
Post not yet marked as solved
0 Replies
385 Views
Hey yall--seemingly once in a blue moon whenever fetchLocation gets called in here from a widget that is requesting location, it calls on the manager's requestLocation, the widget will crash. Crash stack backtrace shows this: And this is the affected code: import Foundation import CoreLocation class WidgetLocationFetcher: NSObject, CLLocationManagerDelegate { let manager = CLLocationManager() private var handler: ((CLLocation?) -> Void)? override init() { super.init() DispatchQueue.main.async { self.manager.delegate = self self.manager.requestWhenInUseAuthorization() } } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { self.handler?(locations.last!) self.handler = nil } func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { print(error) self.handler?(nil) self.handler = nil } func fetchLocation(handler: @escaping (CLLocation?) -> Void) { self.handler = handler self.manager.requestLocation() } } I am not too sure what could even be causing this, although I am running watchOS 10 beta 8 and iPadOS 17 beta 8 on the devices experiencing this crash. Has anyone ever solved this issue?
Posted
by
Post not yet marked as solved
27 Replies
4.4k Views
Since the iOS 17 beta 6 update, my SwiftUI-based watch app, which serves as a companion to the phone app, no longer receives any location updates. Even though the permissions are set to 'When In Use' on the phone, the CLLocation delegate returns the following error every time the app requests a location update: Error Domain=kCLErrorDomain Code=1 "(null)" - The operation couldn’t be completed. (kCLErrorDomain error 1.) Additionally, the SwiftUI map does not display the user's location, indicating that the issue is not related to my CLLocationManager implementation on the watch. While debugging on the watch, I observed that the service acknowledges the permissions as granted. On the phone, my location is displayed accurately. On watchOS 9.6, the same watch app receives location updates as expected. Furthermore, other apps on the watch receive location updates accurately, even on watchOS 10 beta. This issue is not isolated to my device; my colleagues have experienced the same problem with the TestFlight build. I suspect that there may be an issue with my project configuration, although I am unsure why this was not a problem before the watchOS 10 beta. Currently, I am attempting to resolve the issue using: Xcode 15.0 beta 8 (15A5229m) watchOS 10 21R5349b iOS 17 21A5326a It is important to note that the issue is also present in watchOS 10 21R5355a.
Posted
by