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

170 Posts
Sort by:
Post not yet marked as solved
0 Replies
60 Views
I'm stuck fetching location inside iOS app's widget extension running on MacOS. locationManager.authorizationStatus == .notDetermined always returns true, meanwhile main app, running on MacOS has permission for location in MacOS system settings and doesn't have any problems with using geodata. Is it possible to fetch a location inside of iOS app's widget extension running on MacOS and if yes, what could I be doing wrong?
Posted
by stepanick.
Last updated
.
Post marked as solved
3 Replies
324 Views
I am currently working on an app that uses the CLMonitor to check when the user has entered a specific region. When the user enters the region, a new region should be monitored, and the old region should be removed. Currently, I have a startMonitoring() method that contains the event handling logic: func startMonitoringConditions() { Task { monitor = await CLMonitor(MonitorNames.monitorName) if let identifiers = await monitor?.identifiers { if identifiers.count == 0 { if let coordinate = manager.location?.coordinate { await addNewRegionAtCoordinate(coordinate: coordinate) } } else { print("Previous Monitor Region is used.") } } for try await event in await monitor!.events { if let coordinate = manager.location?.coordinate { // do something... await monitor!.remove(event.identifier) await addNewRegionAtCoordinate(coordinate: coordinate) } } } } Unfortunately, adding a new region will not update the events collection in the CLMonitor, so the new region's events will not be handled in this method. Any help on how I could fix this problem would be greatly appreciated!
Posted
by selvi.
Last updated
.
Post marked as solved
1 Replies
94 Views
Hi, Has anyone found a way to send a push notification based on beacon region entry/exit? Since iOS 17, CLBeacionRegion which inherits CLRegion that made this possible is now deprecated and replaced by CLMonitor.CLBeaconIdentityCondition. CLMonitor.CLBeaconIdentityCondition does not only work properly on the latest version of iOS, it also lacks such features like sending push notifications based on region entry/exit. Even UNLocationNotificationTrigger only accepts CLRegion which is not possible to create one using existing classes that are not deprecated.
Posted
by peter292.
Last updated
.
Post marked as solved
1 Replies
58 Views
Hi, I've discovered that my app's location can be manipulated using iMyFone. I've searched extensively online for solutions, but haven't found anything effective. Do you have any insights on how I can prevent this manipulation using Swift code? Thanks for your help in advance.
Posted
by thawdezin.
Last updated
.
Post not yet marked as solved
0 Replies
111 Views
Our app needs the location of the current user. I was able to grant access and the authorization status is 4 (= when in use). Despite of that, retrieving the location fails at almost all times. It returns the error: The operation couldn’t be completed. (kCLErrorDomain error 1.) It happens in both the simulator and on the real device. On the simulator, I can sometimes trick the location to be detected by forcing a debug location in Xcode. But this does not work on the real device. What might be the root cause of this behavior?
Posted
by waldgeist.
Last updated
.
Post not yet marked as solved
0 Replies
135 Views
I have not tested on the lower version but it seems like it is not functioning properly on iOS 17.4. It does work with CircularGeographicCondition but not with BeaconIdentityCondition. I am testing with this example code by Apple. I have typed proper UUID of my iBeacon device but it is never discovered. Some other posts say that it has not been working since iOS 17.3.1. Anyone having the same issue with me?
Posted
by peter292.
Last updated
.
Post not yet marked as solved
3 Replies
145 Views
I have a Python script that returns a scan result with scanForNetworksWithName using CoreWLAN with PyObjC. It provides info on ssid and such like the airport command. When upgrading to MacOS 14.4 however SSID is now Null. I read this was due to changes in permissions and location services needed to be enabled. I have enabled access to location services and I am able to use CoreLocation to get a location however I still do now see the SSID. Here is my script, that does both location and scan: import CoreWLAN import CoreLocation from time import sleep import re wifi_interface = CoreWLAN.CWInterface.interface() networks, error = wifi_interface.scanForNetworksWithName_error_(None, None) location_manager = CoreLocation.CLLocationManager.alloc().init() location_manager.startUpdatingLocation() max_wait = 60 # Get the current authorization status for Python for i in range(1, max_wait): authorization_status = location_manager.authorizationStatus() if authorization_status == 3 or authorization_status == 4: print("Python has been authorized for location services") break if i == max_wait-1: exit("Unable to obtain authorization, exiting") sleep(1) coord = location_manager.location().coordinate() lat, lon = coord.latitude, coord.longitude print("Your location is %f, %f" % (lat, lon)) print(f"{'SSID' : >32} {'BSSID' : <17} RSSI CHANNEL HT CC SECURITY") for i in networks: print(f"{'SSID' : >32} {'BSSID' : <17} RSSI CHANNEL HT CC SECURITY") for i in networks: print(f"{i.ssid() or '' : >32} {i.bssid() or '' : <17} {i.rssiValue() : <4} {i.channel() : <6}") It worked fine in MacOS 13.6 but with MacOS 14.4 I have the null SSID issue. We went through something similar with MacOS 10.15 where BSSID became Null. At the time I couldn't find a workaround, but sometime around MacOS 13.x I was able to generate the request for location services. After granting the request I was able to see BSSID again. It seems like we have a similar bug to this again. Thread about the BSSID issue: https://github.com/ronaldoussoren/pyobjc/issues/484
Posted
by thewade.
Last updated
.
Post not yet marked as solved
0 Replies
106 Views
Hi. I'm looking to schedule a number of notifications based on the user's location and have them be triggered UNLocationNotificationTriggers. I want to know whether notifications get delivered so I can limit the number of notifications the user receives in a day. I was hoping I could determine their delivery by either the UNUserNotificationCenterDelegate's method userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) (which only knows when the user has tapped on the notification or deleted it) or by UNUserNotificationCenter.current().deliveredNotifications() (which should return the notification if it was delivered and is in the Notification Center). UNUserNotificationCenter.current().deliveredNotifications() is not returning notifications that were delivered via UNLocationNotificationTriggers. I'm assuming this is for some privacy reason? All of the UNLocationNotificationTriggers are configured with notifyOnEntry to be true, notifyOnExit to be false, and repeats to be false. They get delivered appropriately, but I can't determine if/when they get delivered to ensure the user doesn't receive too many notifications. Notifications delivered with a UNTimeIntervalNotificationTrigger are returned as expected. Is all of this by design or is there another way to determine when a notification scheduled with a UNLocationNotificationTrigger gets delivered? I'm just trying to create the best experience for my users. Thank you.
Posted Last updated
.
Post not yet marked as solved
0 Replies
83 Views
If they had used .task they could have removed the class LocationsHandler: ObservableObject and simply done: struct ContentView: View { @State var lastLocation: CLLocation? var body: some View { VStack { ... } .task { let updates = CLLocationUpdate.liveUpdates() for try await update in updates { if let loc = update.location { self.lastLocation = loc } } } And saved themselves about 20 or so lines of code. .task was added in the year before so it isn't the case that it wasn't available to the CoreLocation team yet. To wrap async/await in a Combine's ObservableObject is very strange. They could have also used @AppStorage instead of UserDefaults and saved another few lines. To be honest this is some of the strangest SwiftUI code I've seen.
Posted
by malc.
Last updated
.
Post not yet marked as solved
0 Replies
112 Views
Hey I try to post my issue here but keep getting a sensitive problem, so I posted on stack overflow (See here), but really appreciate your help on any forum. The post is about an issue with the auto refresh of the widget and the same behaviour when refreshing from a button in the widget (Done with AppIntent).
Posted
by aimarquez.
Last updated
.
Post not yet marked as solved
0 Replies
63 Views
Hi I want to inquire about the data returned from CoreLocation update and whether it is accurate. I am attempting to retrieve the local address in Japan based on the postal code, and I have observed differences in the returned data. When calling the information retrieval function with the postal code 3360042, the returned data is as follows: Locality: さいたま市 SubLocality: 南区 Corresponding to Japan Post: https://www.post.japanpost.jp/cgi-zip/zipcode.php?pref=11&city=1111080&id=38748 the displayed information on the website includes "Locality + SubLocality". When calling the information retrieval function with the postal code 1350064, the returned data is as follows: Locality: 江東区 SubLocality: 青海 Corresponding to Japan Post japan post: https://www.post.japanpost.jp/cgi-zip/zipcode.php?pref=11&city=1111080&id=38748 the displayed information on the website only includes "Locality" not includes SubLocality. Is it possible that CoreLocation has been updated? The current data seems to deviate from the design of our application. Please provide me with a solution to determine when to use "Locality + SubLocality" versus just "Locality" to obtain the local address. Thank.
Posted Last updated
.
Post not yet marked as solved
1 Replies
211 Views
In our app we have the necessity to gather background location after a trigger from a bluetooth event. During the onboarding we ask for authorizedWhenInUse. CLLocationManageris configured like this, and in capabilities we provided the location flag. let cl = CLLocationManager() cl.delegate = self cl.allowsBackgroundLocationUpdates = true cl.desiredAccuracy = kCLLocationAccuracyBestForNavigation According to apple doc or at least what I understood, this should be enough to obtain locations even when the app is in background (and awake). The system allows background updates for apps with either When in Use or Always authorization. If an app isn't running when an update occurs, the system launches the app only if it has Always authorization and uses the significant location change, visits, or region monitoring services. We saw an inconsistent bahviour, the system request to start the location updates after the bluetooth event (we have background capabilities set also for that). In foreground it work always, but in background sometimes it works and sometimes not. When we don't receive a location we usually get a CLError.denied in the func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) method. At this point I don't get the apple doc quote, is it possible to obtain location in background or not with authorizedWhenInUse?
Posted
by DrAma78.
Last updated
.
Post not yet marked as solved
1 Replies
157 Views
Hello, We have an iOS application which detects when the user starts driving by detecting an USB iBeacon which is installed in the car of the users. For that we are monitoring the iBeacon region with CoreLocation and we are detecting the iBeacon when the locationManager(_:didDetermineState:for:) delegate method is called. We received some reports from a user that the iBeacon monitoring stops working when a specific BT device (specifically a hearing aid) is connected to the iPhone. The hearing aid is connected in the iOS Settings > Bluetooth page, similar how a regular BT headset is connected. When the hearing aid is disconnected then the iBeacon monitoring resumes and starts working properly again. We can't reproduce this issue with our BT headsets, so maybe the problem is specific to just some BT device connections? The advertising time interval of the iBeacon is 100mS as requested in the Apple documentation. Previously we had problems when a phone call was made through a BT headset when we used an advertising interval > 100mS in order to improve the battery usage of the iBeacon. But we changed to use an USB iBeacon, so the battery usage is not a concern anymore. Did somebody experience similar issues or has a solution? Specifically, can some specific BT connections set up in iOS Settings > Bluetooth page interfere with the iBeacon monitoring when using CoreLocation? Thank you very much!
Posted Last updated
.
Post not yet marked as solved
0 Replies
189 Views
I managed to get the entry/exit for beacon region on >iOS 17.0 to <=iOS 17.1.2, but it doesn't work at all on latest iOS version 17.3.1. I have tried the new addition in iOS 17.2, assuming unmonitored as well but still no result. I'm using the sample code provided by apple, https://developer.apple.com/documentation/corelocation/monitoring_location_changes_with_core_location. Please guide.
Posted Last updated
.
Post not yet marked as solved
0 Replies
156 Views
although the Documentation implies that multiple CLLocationManager running in parallel should not intervene one another. I find some evidence that they do: for example a Medium posts title: "Single vs Multi CLLocationManager solutions" states: In multi instances of CLLocationManagers solution, there is the risk of collision where a feature / settings can impacts across instances of CLLocationManagers. another Medium post titled: "Measuring Differences of Degrees Using CLLocation’s CLHeading" states: however an important condition is that Apple recommends you initialize only ONE instance within your application at a time. This is because multiple instances running simultaneously has the effect of causing interference and distorting the data so is there some risk using CLLocationManager in parallel. is the configuration properties such as desiredAccuracy and distanceFilter can interrupt different CLLocationManagers running in parallel?
Posted Last updated
.
Post not yet marked as solved
0 Replies
144 Views
I'm trying to develop a iOS mobile app with using flutter, which can scan nearby wifi access points and connect to a one of them. I ran the app on a physical device with a free apple developer account. When I scan for the wifi access points, it throws an error with saying wifi scan is not supported. I just used wifi_scan library in flutter. Is it required to have a paid developer account to test this feature (wifi scanning and connection) ? Does iOS natively give the access to apps to scan wifi? Thanks
Posted
by Pabasara.
Last updated
.
Post not yet marked as solved
3 Replies
660 Views
I am working on an app where I need to orient a custom view depending on the device heading. I am using ARKit and ARSCNView with the ARGeoTrackingConfiguration in order to overlay my custom view in real world geographic coordinates. I've got a lot of it working, but the heading of my custom view is off. Once the ARSession gets a ARGeoTrackingStatus.State of .localized, I need to be able to get the devices heading (0-360) so that I can orient my view. I'm having trouble figuring out how to do this missing piece. Any help is appreciated.
Posted
by rolson.
Last updated
.
Post not yet marked as solved
0 Replies
162 Views
My macOS application is trying to fetch location, but everytime LocationManager responds with locationUnknown. Application is granted with permission to access location. Issue is seen in only one device with OSVersion: 14.2.1(23C71), chipset: Apple M1 pro. Other devices with same OS don't have this issue. My application is a background agent, means it has given UIElement in the plist. Issue persists even after restarting device, re-installing application, re-applying location permission. But Google Chrome shows correct location when using Openstreet Map or Google Maps. Is there any troubleshoot/alternative methods here? Any idea why it occurs? Code: if CLLocationManager.locationServicesEnabled() { if #available(OSX 10.14, *) { self.locationManager.requestLocation() } else { // Fallback on earlier versions self.locationManager.startUpdatingLocation() } } I need to get location in certain intervals. So After LocationManager updates I stop location with locationManager.stopUpdatingLocation() and request again after the interval.
Posted Last updated
.
Post not yet marked as solved
0 Replies
188 Views
Hi guys! I am trying to extract Location Services data from an iPhone running developer mode, and have installed the "Location Services for iOS" Profile that can be found on the Profiles and Logs page. I have also read the Instructions PDF, and done the setup. I am having a hard time finding the actual logs after exporting the sysdiagnose folder. The folder is quite big and complex. Can someone please help me, and tell me where I can find it? Thanks!
Posted
by rawpotao.
Last updated
.