Core Location

RSS for tag

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

Posts under Core Location tag

154 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

App is getting crashed after sign the application
PLATFORM AND VERSION macOS Development environment: Other: Python Run-time configuration: macOS 14.6.1 DESCRIPTION OF PROBLEM We have created application using python and created .app using pyInstaller. We want to get the location access using python based application which we are trying to run on MacOS 14.6.1. Without including NSLocationUsageDescription in our info.plist, it is working fine but not getting location permission pop up. After including NSLocationUsageDescription in info.plist application got corrupted. STEPS TO REPRODUCE We are using below commands to sign the application codesign --force -s "Developer ID Application: Pitney Bowes (72NX38Y9GF)" -v DeviceHub.app --deep --strict --options=runtime --entitlements ../info.plist DeviceHub.app ditto -c -k --keepParent --rsrc --sequesterRsrc --arch 'x86_64' DeviceHub.app DeviceHub.zip xcrun notarytool submit DeviceHub.zip --keychain-profile "DHAgentProfile" --wait xcrun stapler staple DeviceHub.app
2
0
112
3d
Add the capability of "Access Wi-Fi information" and show the location access indicator
We met a question recently in our project, we try to achieve the SSID,so we need to do the following two things : request location permission add the capability of "Access Wi-Fi information" then the app always shows the location access indicator. , In the app privacy report , we see the app always request the location. But when I try to remove "Access Wi-Fi information" the capability , the scenario disappear. Any ideas can explain this ? How can I remove the location access indicator with out remove the "Access Wi-Fi information" . I indeed need this. Thanks in advance.
1
0
105
1w
Not getting User's location in Background Mode
We developed a app in which the I need the app to update the User's location even in background( even after terminating from the recent UI ), Currently I am receiving the location updates when the user has kept the app in open and if minimised, But I want that it should update the location even when it is removed from recent app (minimised UI)(after terminating the app) Is it possible to do so.???
1
0
179
1w
What is the reason for the CLLocationmanager.locationServicesEnabled() "invoked on main thread" warning?
I am looking into a piece of old code where the mentioned method is called. + (bool)isLocationServicesEnabled { return [CLLocationManager locationServicesEnabled]; } I'm getting the classic "This method can cause UI unresponsiveness if invoked on the main thread. Instead, consider waiting for the -locationManagerDidChangeAuthorization: callback and checking authorizationStatus first." I have 2 questions: What is that error about, really? The locationServicesEnabled() has nothing to do with authorisation, it's just about the "location services" settings global on-off switch? (the authorisation check is .authorizationStatus) I don't understand why that call is such a big issue? It's just a setting? Why would that be so costly? Thankful for pointers! Have a good one
5
0
201
1w
How can I get something similar to launchOptions[UIApplication.LaunchOptionsKey.location] in SceneDelegate for iOS 13+ apps
I'm making an app for iOS 13+ devices. My project has both app delegate and scene delegate files. I'm using core location for significant location changes. I was able to detect significant location changes and system waking up my app in simulator using SignificantlyChanged app’s scheme. But when the launch options dictionary has 0 elements and the value for the key UIApplication.LaunchOptionsKey.location is always nil. Here is my AppDelegate.swift where the system will launch the app in background state when a significant location change is detected and execute the location fetch code. And location manager class. I want to know if the app is launched my the system or if it is launched by the user so I want to check if UIApplication.LaunchOptionsKey.location key has a value. But it is always nil and there is no alternative to it in SceneDelegate. When and how can I find a solution to this long due issue. import CoreLocation @main class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. if launchOptions != nil{ if launchOptions![UIApplication.LaunchOptionsKey.location] != nil{ print("Called from background location fetch") } } LocationService.shared.askForPermission() LocationService.shared.delegate = self return true } // MARK: UISceneSession Lifecycle func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { // Called when a new scene session is being created. // Use this method to select a configuration to create the new scene with. return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) } func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { // Called when the user discards a scene session. // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. // Use this method to release any resources that were specific to the discarded scenes, as they will not return. } } extension AppDelegate: LocationMangerDelegate{ func didFetchLocation(coordinate: CLLocationCoordinate2D) { print(coordinate) } func didFailToFetchLocation(error: Error?, message: String) { print(message) } }``` import Foundation import CoreLocation protocol LocationMangerDelegate: AnyObject{ func didFetchLocation(coordinate: CLLocationCoordinate2D) func didFailToFetchLocation(error: Error?,message: String) } class LocationService: NSObject{ private override init() { } weak var delegate: LocationMangerDelegate? static var shared = LocationService() lazy var locationManager: CLLocationManager = { var manager = CLLocationManager() manager.desiredAccuracy = kCLLocationAccuracyBest manager.allowsBackgroundLocationUpdates = true manager.pausesLocationUpdatesAutomatically = false manager.delegate = self return manager }() func askForPermission(){ print("INSIDE") locationManager.requestWhenInUseAuthorization() } func startLocationUpdates(){ self.locationManager.startUpdatingLocation() } func stopLocationUpdates(){ self.locationManager.stopUpdatingLocation() } } extension LocationService: CLLocationManagerDelegate{ func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) { let status = manager.authorizationStatus switch status { case .notDetermined: self.askForPermission() case .restricted: self.delegate?.didFailToFetchLocation(error: nil, message: "Location permission is restricted by the user") case .denied: self.delegate?.didFailToFetchLocation(error: nil, message: "Location permission is denied by the user") case .authorizedWhenInUse: self.locationManager.requestAlwaysAuthorization() case .authorizedAlways: self.locationManager.startMonitoringSignificantLocationChanges() @unknown default: break } } func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { if let location = locations.first{ print(location) self.delegate?.didFetchLocation(coordinate: location.coordinate) self.stopLocationUpdates() } } func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { print(error) self.delegate?.didFailToFetchLocation(error: error, message: error.localizedDescription) } }
1
0
179
1w
Push Location Service Entitlement
Hello! Back on April 4th our team requested the push location service entitlement. Our app requires very similar background tracking as Find my or Life 360 where users agree to share locations and another user might want to prompt for an update. Since submitting on April 4th, we have received no response or update from our request. I've called and emailed with developer support 20+ separate times (They've escalated it at least 10 times at this point) with no response either. I've also submitted new requests in case our original got lost. Is there anyone else we can contact or talk with to get any progress? The developer support team is even at a loss for how long this is taking now. We are just completely lost on what our next step could be
0
0
187
Aug ’24
Requirement of location services to get SSID name.
Sorry if this has been asked before. I was looking if there was any specific reason why location permission is needed to SSID name? I built small utility app to show network details. Some users have expressed concerns regarding enabling location services just to get the SSID or BSSID values. Just want to understand, and hopefully convey the right message to the users.
3
0
252
Aug ’24
How can I ensure that the GNSS received on iOS is reliable at the decimeter to centimeter level?
I am trying to use GNSS data to track the location of a mobile phone with high precision. I understand that using Fused Location provided by iOS can improve accuracy, but it is not perfect. To inform the user when the current GNSS location is somewhat inaccurate (with meter-level error), which data fields should I rely on? (e.g., horizontal accuracy, vertical accuracy) Additionally, I am curious if iOS currently supports dual-band GNSS calculations (e.g., SBAS, BeiDou-3, etc.). If supported, which API can be used to determine this status?
1
0
220
Aug ’24
xcode 15.4 [Debug] -> [Simulate Location] with custom gpx is broken
I'm using location simulation on my device via xcode a lot and it worked as expected since yesterday. Now it's broken :( My custom gpx files are no longer visible in "Simulate Location". I only see the build-in locations. When I try to add a new gpx file with "Add GPX File to Workspace..." the gpx files are greyed out. I created a new project and same here. No custom GPX files shown and cant add via menu. I'm using xcode 15.4 and it worked before, but I updated to macOS 14.6 last week. Did someone have experienced the same ? The Internet has no sign of such a behavior :( Maybe the file association is broken? I already removed xcode and user data related to xcode completly and reinstalled xcode, but this was not helping.
3
1
244
Aug ’24
locationManager(_ manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], in region: CLBeaconRegion) not working
The delegate method : locationManager(_ manager: CLLocationManager, didRangeBeacons beacons: [CLBeacon], in region: CLBeaconRegion) is giving no values in beacons for iOS 18 beta iPhone device in XCode 16 beta while the same code works and gives correct beacons on same peripheral and central devices in iOS 17. Has something changed in iOS 18 beta or is it iOS 18 beta bug related to beacons?
1
0
203
Aug ’24
How to Open Privacy & Security Location Services Programmatically
I'm an iOS mobile developer working on handling location permissions. I've observed that some apps, even recent ones available on the App Store, can automatically navigate to the settings path: Settings -&gt; Privacy &amp; Security -&gt; Location Services when the device's location services are turned off. However, most examples and best practices recommend using UIApplication.openSettingsURLString, which does not meet my requirements. This function only opens the app's specific location permissions, not the device-wide location services toggle. I'm looking for a way to programmatically open the Privacy &amp; Security -&gt; Location Services settings page directly. Any insights or solutions for achieving this functionality in a compliant and sustainable manner would be greatly appreciated. Thank you in advance for your help!
1
0
269
Aug ’24
requestWhenInUseAuthorization Crash iOS 18 Beta 4
When I call requestWhenInUseAuthorization in state kCLAuthorizationStatusNotDetermined on iOS 18 Beta 4 in the simulator, all my apps just terminate without any error message in the Xcode console (black screen with an activity indicator for a second or two and then it goes back to the springboard). I do have the NSLocationWhenInUseUsageDescription set in my Info.plist file. When running the exact same apps in Xcode 16.0 beta 4 (16A5211f) but with a iOS 17 simulator attached, it is working as expected by showing the location authorization dialog. Is this a known issue or am I missing something?
3
1
398
Aug ’24
Expected behavior of CLServiceSessions(.always) after device restart?
Hi! I was wondering what the expected behavior of CLServiceSession(authorization: .always) after a device restart was? What I am observing right now is that, after a device restart, location access from the background is denied until the app enters the foreground for the first time (CLServiceSession.Diagnostic says insufficientlyInUse: true; CLLocationUpdate additionally says serviceSessionRequired: true). Is this the expected behavior? If it is, then this seems like a somewhat suboptimal user experience to me, at least for my use case - the user's intention regarding the background location access won't have changed just because the device was rebooted. (In case this is relevant, my use case is transmitting the current location to connected Bluetooth devices, e.g. digital cameras. As such my app is setting UIBackgroundModes of ["bluetooth-central”]).
3
0
252
Aug ’24
Location interval on the iOS platform, with Flutter's Geolocator
Hey guys. I'm building a cross-platform app using Flutter, which uses the Geolocator package to see how far the user has travelled from their starting point, aviation related. I do allow the user to select their own distance filter value from a set of pre-defined options, which could be as low as a metre, since the app is designed for use over relatively small distances, from say 200m to 1km. Therefore, having a large distance filter value wouldn't make much sense. However, the issue I am having is that with iOS, I can't seem to control the actual sample rate of the user's location. From what I gather, iOS measures the user's location approximately once every second, give or take a bit, but that value cannot be changed. That's quite different to Android, where I can specify this measurement interval to be whatever I want it to be. This lack of ability to control the measurement interval tends to cause quite a lag. When someone first starts to move, they aren't travelling fast enough to cause a noticeable lag. However, when someone's speed picks up, they could be travelling at around 70mph/32m/s (ish). If you're only measuring the user's location once every second, then it's likely they will have travelled over 30m before the next location update, which means the lag distance could potentially be huge relative to the maximum distance they will measure using the app. I do fully appreciate that this is native functionality to iOS but my question really is, is there perhaps a way around this? Is there any way to increase the frequency with which the user's location is retrieved, so that I can reduce this lag? If there isn't, that's no problem at all. I just thought I would ask the question, incase someone has come across this before and found a solution that works. These are the Apple-related settings that I have been able to control with Flutter, for the Geolocator package. Thank you in advance! locationSettings = AppleSettings( accuracy: LocationAccuracy.bestForNavigation, activityType: ActivityType.otherNavigation, distanceFilter: distanceFilterValue, pauseLocationUpdatesAutomatically: false, showBackgroundLocationIndicator: false, );
2
0
301
Jul ’24
Crash when CLLocationUpdate.liveUpdates is called while requesting authorization by CLServiceSession
I watched this video and programmed with this sample code as a reference. The application crashed when I toggled the switch with the following code. // // ContentView.swift // LiveUpdatesInCoreLocation // import os import SwiftUI import CoreLocation @MainActor final class ContentViewModel: ObservableObject { private let logger = Logger() @Published var updatesStarted: Bool = false { didSet { updatesStarted ? self.startLocationUpdates() : self.stopLocationUpdates() } } func startLocationUpdates() { Task { let _ = CLServiceSession(authorization: .whenInUse) for try await update in CLLocationUpdate.liveUpdates() { guard self.updatesStarted else { break } logger.debug("update location: \(update.location)") } } } func stopLocationUpdates() {} } struct ContentView: View { @StateObject private var model = ContentViewModel() var body: some View { VStack { Toggle("Location Updates", isOn: $model.updatesStarted) } .padding() } } And this is the error that occurred. Thread 8: EXC_BAD_ACCESS (code=1, address=0x10) A bad access to memory terminated the process. If you remove the below code, the error will not occur. let _ = CLServiceSession(authorization: .whenInUse) Therefore, I guess that the problem is in calling CLLocationUpdate.liveUpdates while CLServiceSession is requesting authorization. or am I doing something wrong?
2
0
276
Jul ’24
Location in the Background constant popups
We have a pair of apps that are used to monitor the location of a person and allow them to reach out for help when needed. The apps are designed to be used with persons with special needs. A large portion of our target audience is people that have cognitive disabilities. One app is used by people that monitor and help the person with needs, and the other is used by the person with needs who is not with them all the time. The issue we have is that our users have trouble understanding what to do when this verification popup appears. This popup continues to appear over and over and over. This is a severe health and safety issue for us. We find that the user is often times confused by the popup and is disabling the background location tracking preventing the needs provider from being able to track the location of the user. It would be great if there was a special Entitlement that could be granted that would prevent this 'feature' of iOS. Or possibly simply a setting that the user's provider can setup on their phone to stop the annoying and dangerous constant popups. If anybody knows of a way to prevent this popup, please let us know. Otherwise, if someone at Apple could suggest how we can make this happen in the future.
3
0
386
Jul ’24