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
33 Views
Hi, Per Apple the isStationary value is supposed to set to true when the device is stationary. I am trying to get a better understanding of when and how this status is changed. When and how does Apple decide when to set this to true and what is the threshold by which it is set to false. Right now when I start my app and use it is set from true to false instantly. let updates = CLLocationUpdate.liveUpdates() for try await update in updates { self.isStationary = update.isStationary I would love to know by what criteria it sets it to true otherwise I'm collecting a lot of zero speed very slight to no movements in latitude and longitude that I have to make some assumptions about filtering out of what I capture. I can't seem to find any mention of this or use case examples in any of the usual sources for examples despite having been introduced at the last WWDC 2023. Any help here would be appreciated.
Posted Last updated
.
Post not yet marked as solved
0 Replies
70 Views
Hello, I developed an application that uses iBeacons to create events, however when the app is in the terminated state I notice that part of my code is activated but the rest of the process is not activated ex : ranging beacon and notification. Is there a way to completely wake up my app when it is in terminated state or at least send a notification to the user to inform them that the app must be opened to put it back in background state so that the app working correctly?
Posted
by JMG22.
Last updated
.
Post not yet marked as solved
0 Replies
95 Views
I’m working on updating one of my apps to the asynchronous location updates API, but have been running into an unhelpful error. Here's my code: @Observable class CurrentLocation: NSObject, CLLocationManagerDelegate { private(set) var location: CLLocation? private let locationManager = CLLocationManager() override init() { super.init() self.locationManager.delegate = self self.locationManager.desiredAccuracy = kCLLocationAccuracyReduced } func requestLocation() async throws { print("requesting location") requestAccess() for try await update in CLLocationUpdate.liveUpdates() { self.location = update.location if update.isStationary { break } } } } But after calling requestLocation(), I receive the following error in the console without any location updates: {"msg":"#locationUpdater received unhandled message", "Message":kCLConnectionMessageCompensatedLocation, "self":"0x600002eaa600"} Googling this error yields absolutely no matches. I’ve ensured that I have the necessary Info.plist entries (as the old, synchronous location update code I have is also working without issues). I’d be grateful for any assistance!
Posted
by dte.
Last updated
.
Post not yet marked as solved
1 Replies
138 Views
I'm getting a report from QA that an App which normally launches from the background through significant location monitoring does not launch after the phone was restarted and the device was never unlocked. I have no idea how or where I would begin with a diagnosis of this. Anyone have any ideas? iOS: 17.2.1
Posted
by Hogdotmac.
Last updated
.
Post not yet marked as solved
1 Replies
163 Views
My MacBook Air M2 system version macOS Sonoma 14.5 Beta (23F5049f) The error occurred: from the end of March 2024 to today (April 8, 24) Problem: The system positioning information is seriously wrong, including but not limited to: time zone, Safari, map app, weather app, search app... (PS. The positioning is correct when using Google Chrome and Google Maps, but it is still wrong when using Google Maps on Safari) Background: I came to Germany from mainland China at the end of March. The Apple ID region I use is Germany. The location of my iPhone and Apple Watch can be refreshed to Germany normally, and several of my AirTags have been refreshed to Germany. Tried but failed: I searched for some bash commands to try to clear and clear the cache of the map app and system location information. rm -rf ~/Library/Containers/com.apple.Maps rm -rf ~/Library/Application\ Support/com.apple.findmy sudo rm -rf /Library/Caches/com.apple.GeoServices sudo rm -rf /Library/Caches/com.apple.locationd defaults delete com.apple.locationd.plist Turn off location services in System Settings > Privacy and Security, shut down and restart the phone, and then turn the service back on. Turn my VPN on and off. Clear my network information. Since there are many files saved, the restore operation is not planned. 我的MacBook Air M2 系统版本macOS Sonoma 14.5 Beta版(23F5049f) 错误发生时间:2024年3月底到今天(24年4月8日) 问题:系统定位信息严重错误,包括但不限于:时区、Safari、地图app、天气app、查找app... (PS.使用Google Chrome浏览器与Google Maps时定位正确,Safari使用Google Maps仍然错误) 背景: 我从3月底从中国大陆来到欧洲德国。 我使用的Apple ID地区是德国的。 我的iPhone和Apple Watch定位能正常刷新到德国,且我几个AirTag已经刷新到德国。 尝试但都未成功: 我搜索了一些bash命令尝试清除、清空地图app和系统位置信息的缓存。 rm -rf ~/Library/Containers/com.apple.Maps rm -rf ~/Library/Application\ Support/com.apple.findmy sudo rm -rf /Library/Caches/com.apple.GeoServices sudo rm -rf /Library/Caches/com.apple.locationd defaults delete com.apple.locationd.plist 关闭系统设置>隐私与安全中的定位服务,关机重启,再重开这项服务。 开关我的VPN。 清除我的网路信息。 由于保存的文件较多,不打算进行还原操作。
Posted
by TifaPlove.
Last updated
.
Post not yet marked as solved
0 Replies
113 Views
"When an iBeacon is received, a BLE scan API is called within didEnterRegion. However, if executed while the screen is off, Core Bluetooth's didDiscover does not function. Yet, if the screen is turned on once and then turned off again, didDiscover functions. Is there a way to make Core Bluetooth's didDiscover work while the screen is off?" Let me know if you need further assistance or clarification! func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) { if let beaconRegion = region as? CLBeaconRegion { startRanging(in: beaconRegion) } } func startRanging(in beaconRegion: CLBeaconRegion) { // バックグラウンドタスクを開始 bgTask = UIApplication.shared.beginBackgroundTask(expirationHandler: { [self] in print("バックグラウンドタスクの有効期限が切れ") // バックグラウンドタスクの有効期限が切れたときに、バックグラウンドタスクを終了 self.lm!.stopRangingBeacons(satisfying: beaconRegion.beaconIdentityConstraint) UIApplication.shared.endBackgroundTask(bgTask) // バックグラウンドタスクの識別子を無効 bgTask = .invalid }) // レンジング開始 self.lm!.startRangingBeacons(satisfying: beaconRegion.beaconIdentityConstraint) //サービス指定してCoreBluetoothを起動 self.centralManager.stopScan() self.centralManager.scanForPeripherals(withServices: [self.kServiceUUID], options: nil) // バックグラウンドタスク終了 let time = UIApplication.shared.backgroundTimeRemaining - 1.0 DispatchQueue.main.asyncAfter(deadline: .now() + time) { self.stopRanging(in: beaconRegion) } } func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) { print("---- didDiscover ----") print("peripheral-->\(peripheral)") print("advertisementData-->\(advertisementData)") print("rssi-->\(RSSI)") print("---------------------") }
Posted
by tgrgenki.
Last updated
.
Post not yet marked as solved
0 Replies
133 Views
I'm currently working on an app that requires location-based notifications, particularly utilizing geofencing to trigger alerts when a user enters specific areas, such as when a student walks into a college campus. However, I'm curious about the behavior of such notifications when the app is fully terminated and not running in the background. Does anyone have experience implementing geofencing and location-based notifications in apps that are fully terminated? Are these functionalities still active, or does the app need to be running in the background for them to work properly? Any insights, experiences, or best practices regarding this matter would be greatly appreciated. Thank you in advance for your help!
Posted
by Mordechai.
Last updated
.
Post not yet marked as solved
0 Replies
196 Views
Hello dear when i use geolocator after i'll get this error Could not build the precompiled application for the device. Error (Xcode): Undefined symbol: OBJC_CLASS$_LocationServiceStreamHandler Error (Xcode): Undefined symbol: OBJC_CLASS$_PositionStreamHandler Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation) Error launching application on iPhone. and didn't app running so plz guide i'm a too much upset
Posted
by AliSindhi.
Last updated
.
Post not yet marked as solved
0 Replies
169 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
432 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
192 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
147 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
198 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
241 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
4 Replies
346 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
205 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
174 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
208 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
.