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

135 Posts
Sort by:
Post not yet marked as solved
1 Replies
306 Views
If I enroll in Indoor Maps, and provide Apple with detailed wi-fi positioning from the building, will iOS users inside that building get more accurate GPS results? I mean, will Apple use the data we provided to give better positioning? Or only if I'm using the MapKit (we already have an interface built, and would NOT be using Apple's).
Posted
by Codezone.
Last updated
.
Post not yet marked as solved
1 Replies
200 Views
I’m trying to prevent the user from spoofing his current location using third party software, for ex: imyfone anyto or something similar, is CLLocationSourceInformation supposed to detect this behavior or not? I couldn’t find much information about this API.
Posted Last updated
.
Post not yet marked as solved
0 Replies
178 Views
Hello everyone! Got the question about how user might be prohibited of quitting application. The scenario is looking like company wants to see always where employee located. They need always monitoring GPS coordinates and avoid the situation when user killing application manually. Is there any way to disallow user ability to quit an application or restart it somehow automatically if it has quitted? Therefore some subquestions: How determine user killed application or it has killed by system? How to auto-run application at time of device start? Is there any way to run application like service/daemon? (previously there were no any such functionality maybe appeared now?) Or any other solution that might be simulating service behaviour? Is there any additional abilities for application developing if the app distributed under corporate account and not published for everyone via AppStore?
Posted
by a.bogong.
Last updated
.
Post marked as solved
8 Replies
7.3k 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 Last updated
.
Post not yet marked as solved
0 Replies
146 Views
Hi! I'm new to Swift and I'm trying to build a simple app with a feature that will allow a user to send an sms that automatically includes their location. I've got the sending of the message covered however I'm lost at how I can automatically put the user's current location in the message's body. Any kind of help would be much appreciated, thank you! Here is my code so far: import SwiftUI import CoreLocation import UIKit  struct MessageView: View {     @State private var isShowingMessages = false       var body: some View {         Button("Show Messages") {             self.isShowingMessages = true         }         .sheet(isPresented: self.$isShowingMessages) {          MessageComposeView(recipients: ["09389216875"], body: "Emergency, I am here with latitude: \(locationManager.location.coordinate.latitude); longitude: \(locationManager.location.coordinate.longitude) {messageSent in print("MessageComposeView with message sent? \(messageSent)") \\ I currently get an error in this chunk                 }     }     } class ViewController: UIViewController, CLLocationManagerDelegate {    var locationManager: CLLocationManager!   override func viewDidLoad() {         super.viewDidLoad()         locationManager = CLLocationManager()         locationManager.delegate = self         locationManager.requestWhenInUseAuthorization()     } func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {         if status != .authorizedWhenInUse {return}         locationManager.desiredAccuracy = kCLLocationAccuracyBest         locationManager.startUpdatingLocation()         let locValue: CLLocationCoordinate2D = manager.location!.coordinate         print("locations = \(locValue.latitude) \(locValue.longitude)")     } }
Posted
by Seven_7.
Last updated
.
Post not yet marked as solved
0 Replies
177 Views
My app has a problem updating location after resetting location service to enable. So when the system location service is enabled, my app has no problem updating the location. But if I closed the app and disabled the system location service, then restart the app, it will show an alert to enable the system location service. After enabling location service, then going back to the app, its location has no updating at all. I have the longitude, latitude, heading..etc UIs to indicate whether the location is updated or not. Here are my view's code and location manager class, could someone help me out? Thanks View struct ContentView: View { @StateObject private var locationManager = LocationManager() @State var trackingInfo = ARViewContainer.TrackingInfo() @State var isLocationServiceOff = false var body: some View { ZStack { ARViewContainer(trackingInfo: $trackingInfo) .edgesIgnoringSafeArea(.all) .onAppear{ if CLLocationManager.locationServicesEnabled() { locationManager.checkIfLocationServicesIsEnabled() } else { isLocationServiceOff = true } } .alert(isPresented: $isLocationServiceOff) { Alert(title: Text("Location Service Disabled"), message: Text("Geospatial experience requires location service enabled"), primaryButton: .default(Text("Setting")){ if #available(iOS 10.0, *) { if let url = URL(string: "App-Prefs:root=Privacy&path=LOCATION") { UIApplication.shared.open(url, options: [:], completionHandler: nil) } } else { if let url = URL(string: "prefs:root=LOCATION_SERVICE") { UIApplication.shared.open(url) } } }, secondaryButton: .cancel(Text("Cancel"))) } } } } } LocationManager class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate { //User could turn location service off, so it's an optional. var locationManager: CLLocationManager? func checkIfLocationServicesIsEnabled() { if CLLocationManager.locationServicesEnabled() { locationManager = CLLocationManager() locationManager!.delegate = self } } private func checkLocationAuthorization() { guard let locationManager = locationManager else { return } switch locationManager.authorizationStatus { case .notDetermined: locationManager.requestWhenInUseAuthorization() case .restricted: print("Restricted location services due to parental controls") case .denied: print("You have denied this app location permission. Go into settings to change it") case .authorizedAlways, .authorizedWhenInUse: locationManager.desiredAccuracy = kCLLocationAccuracyBest locationManager.allowsBackgroundLocationUpdates = true @unknown default: break } } func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) { checkLocationAuthorization() } }
Posted Last updated
.
Post not yet marked as solved
0 Replies
154 Views
We'd like to generate reports on the number of users who either turn on or off location when prompted by either the OS or our app. Is this possible via Apple Analytics, or is there a programmatic way to accomplish the same thing with a long-lived CLLocationManager?
Posted
by MaBell.
Last updated
.
Post not yet marked as solved
2 Replies
200 Views
I am starting to use CLLocationButton in my apps, but can see an issue with its behavior. When the user taps on a UIButton it is visually noticeable that it's being tapped. Color/Alpha change, image adjusts, etc... When the user taps on a CLLocationButton there is no queues as to it being pressed. I've had several test users complain already that they think the button is not working given that the action might not result in an immediately change to the UI. Apple FB: FB10019792 Open Radar: https://openradar.appspot.com/FB10019792
Posted
by hotngui.
Last updated
.
Post not yet marked as solved
4 Replies
3.5k 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 Bussa.
Last updated
.
Post not yet marked as solved
1 Replies
273 Views
I'm not sure if this is the right place to post about this, so if it is not please direct me to where the right place would be. My mom complained about poor battery life on her iPhone 12 running the latest iOS at the time of this post (15.4.1). I noticed her phone was showing the blue indicator behind the time meaning an app was actively using its location. I clicked it and the Shopkick app opened. I made sure location access for the app was set to while using the app. I even changed it to ask each time and when i went back into the app give it location access once then left surely enough the blue status bar indicator reappeared. According to the App Privacy report on her phone the app was accessing the location of her phone once per minute and the only thing I could do was to set location access for the app to never or uninstall the app. I then restored a test iPhone (SE First Generation) with iOS 15.4.1 downloaded the Shopkick app, signed in and gave it the permissions it wanted including location access by tapping "Allow Once" and after opening and closing the app twice it did the same thing on that phone. I'm not sure if this is a problem with iOS or the developers of the Shopkick app are doing something to get around Apple's location permissions. I should add that background app refresh for app was off for all phones tested. This is also still a problem on iOS 15.5 Beta 3 (it doesn't seem to happen every time). However, on my iPhone 13 Pro Max running an older version of iOS 15, the app continues to receive my location only until I close it from the app switcher making me assume it's an iOS issue. Attached is an App Privacy Report (trimmed to fit the size limit) from the test device left overnight with the app force closed, background app refresh off, and location services for the app set to while using the app which shows the app receiving location info once per minute which I don't think is supposed to happen under those conditions unless i'm missing something. Thanks in advance! log-file
Posted
by Mighty_.
Last updated
.
Post not yet marked as solved
1 Replies
123 Views
The "Getting Started with iBeacon" document recommends using an iOS 7 compatible device or later to calibrate an iBeacon. Given that this document is probably a little dated, does anyone know of a more current recommendation device for calibration? e.g. iPhone 8 and newer, running iOS 12+?
Posted Last updated
.
Post not yet marked as solved
4 Replies
929 Views
I'm trying to diagnose a crash we're seeing in an app that's on TestFlight at the moment. We have the background location permission and are woken by various events, e.g. the significant location change event. I believe the app is being woken in the background and within a few seconds (about 7s in the example below) the app crashes. The crash appears to be when we are confirming what location authorisation the app currently has. As far as we know this is only happening for a single user. Any thoughts on what could be happening? Other forum posts led me to believe it was related to leaking background tasks but I didn't think that was likely after only 7s (and there's no actual mention of background tasks in the crash). Other threads in the crash log have core data relate tasks going on and while we've done a lot of work on our multi-threaded core data I could imagine that being a cause, but surely that would show as a crash on the threads involved rather than thread 0? Any help appreciated, crash log below. John AppVariant: 1:iPhone9,3:15 Beta: YES Code Type: ARM-64 (Native) Role: Non UI Parent Process: launchd [1] Date/Time: 2021-12-13 10:31:18.0065 +0000 Launch Time: 2021-12-13 10:31:11.4169 +0000 OS Version: iPhone OS 15.1 (19B74) Release Type: User Baseband Version: 6.00.00 Report Version: 104 Exception Type: EXC_CRASH (SIGKILL) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Triggered by Thread: 0 Thread 0 name: Thread 0 Crashed: 0 libsystem_kernel.dylib 0x00000001bdd7cb10 mach_msg_trap + 8 1 libsystem_kernel.dylib 0x00000001bdd7d134 mach_msg + 72 (mach_msg.c:119) 2 libdispatch.dylib 0x0000000183f9c734 _dispatch_mach_send_and_wait_for_reply + 504 (mach.c:815) 3 libdispatch.dylib 0x0000000183f9caec dispatch_mach_send_with_result_and_wait_for_reply$VARIANT$mp + 52 (mach.c:2019) 4 libxpc.dylib 0x00000001de30f458 xpc_connection_send_message_with_reply_sync + 236 (connection.c:974) 5 Foundation 0x0000000185a0387c __NSXPCCONNECTION_IS_WAITING_FOR_A_SYNCHRONOUS_REPLY__ + 12 (NSXPCConnection.m:223) 6 Foundation 0x0000000185a09194 -[NSXPCConnection _sendInvocation:orArguments:count:methodSignature:selector:withProxy:] + 2368 (NSXPCConnection.m:1649) 7 Foundation 0x0000000185a49f8c -[NSXPCConnection _sendSelector:withProxy:arg1:arg2:arg3:] + 148 (NSXPCConnection.m:1294) 8 Foundation 0x00000001859ece6c _NSXPCDistantObjectSimpleMessageSend3 + 80 (NSXPCDistantObject.m:282) 9 CoreLocation 0x000000018b0bba0c -[CLLocationInternalClient getAuthorizationStatus:forBundleID:orBundlePath:] + 140 (LocationInternal.m:786) 10 CoreLocation 0x000000018b0ba1fc CLInternalGetAuthorizationStatus + 268 (LocationInternal.m:2063) 11 CoreLocation 0x000000018b0df1c4 +[CLLocationManager _authorizationStatusForBundleIdentifier:bundle:] + 80 (CLClient.mm:1391)
Posted
by mcknut.
Last updated
.
Post not yet marked as solved
7 Replies
6.8k 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 Last updated
.
Post not yet marked as solved
0 Replies
161 Views
Hello Is there any way to access Motion Sensors (CMMotionActivityManager) when the application is in a Suspended state I am able to access sensor updates when I use from Location Service With startUpdateLocation, but this solution comes with bad battery performance Is there any way to access it with the startMonitoringSignificantLocation() service, this location service is not consuming more battery Or is there any other way to access the sensor update while application in suspended state Thank you
Posted Last updated
.
Post not yet marked as solved
0 Replies
140 Views
Is it possible to periodically (or as soon as the OS is able to) call the app from Termination state to Background state (using Location updates capability and creating and exiting Regions), setting up a background task to get location and send JSON data to backend using URLSession on applicationWillTerminate? According to the documentation, Region Monitoring does trigger the app to run when the user either enters a region or exits a region. But URLSession has not been working after the app terminates. Would I need to use Async for that?
Posted
by ocheez.
Last updated
.
Post not yet marked as solved
0 Replies
159 Views
I tried to get SSID and BSSID from iphone running with IOS 15.1. it always return null, even my app has authorization to access precise location. According to the document, from IOS 14. an APP can get SSID and BSSID of the current Wi-Fi network when it meets one of following 4 requirements: application is using CoreLocation API and has user's authorization to access precise location. application has used NEHotspotConfiguration API to configure the current Wi-Fi network. application has active VPN configurations installed. application has active NEDNSSettingsManager configuration installed. In my case, I have the authorization to access precise location, but still I can't get SSID and BSSID. Please advise.
Posted
by hegar52.
Last updated
.
Post not yet marked as solved
0 Replies
164 Views
Hello there, I'm using firebase to push notification with data is: { "notification": { "title": "Title notification", "category": "GENERAL", "body": "body notification", "sound": "default" }, "mutable_content": true, "data": { "title": "Title message", "body": "Body message.", "idhit": "a043dada-1208-4067-b5b6-50bc8578bfc3", "gmtdatetimeid": "620989200", "typehit": 0, "carnumber": "ABC123", "alertname": "Unauthorized Vehicle", "gmtDatetime": "2020/06/05 07:28:30.929", "latitude":"10.792332496703715", "longitude":"106.68018372088815" }, "registration_ids": [ "eBStmdlNfUzJghm1KwpKr-:APA91bGcqODroQnUKKOvJmlg3Vs1ej9Zq-" ] } when my app receive data, i want to get GPS of device and compare it with gps from notification. How do did it, thanks!!!
Posted Last updated
.
Post not yet marked as solved
0 Replies
150 Views
Hi everyone. I am facing a very weird issue where the Location Manager's init method is being called over 100 times on app launch. I have added a print statement to the class init() and when I filter the results from the log I get a staggering 117 entries just in the first few seconds. Here is my setup: class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate {     private let locationManager: CLLocationManager     @Published var locationStatus: CLAuthorizationStatus?     @Published var lastLocation: CLLocation?     override init() {         //initial setup for location monitoring         locationManager = CLLocationManager()         locationManager.requestAlwaysAuthorization()                super.init()         locationManager.delegate = self         locationManager.allowsBackgroundLocationUpdates = true         locationManager.activityType = .other         locationManager.pausesLocationUpdatesAutomatically = false         locationManager.desiredAccuracy = kCLLocationAccuracyBest         locationManager.showsBackgroundLocationIndicator = false locationManager.startMonitoringSignificantLocationChanges()         startMonitoringHomeGeofence()         let monitoredRegions = locationManager.monitoredRegions         print("Monitored Regions: \(monitoredRegions.description)")         print(" | Location Monitoring setup complete(This is the line that is printed out so often)")     } } And in my apps main view I initialize the object with: @StateObject var locationManager = LocationManager() I am not sure if this is a real problem, but as this method also initializes the region monitoring which to my knowledge should only be called once on startup and the fact that I get a burst of location updates on my server every time the app launches makes this behavior look like a error in my code, or a bug on apples side. Has anyone got some ideas for me? Take care David
Posted Last updated
.
Post marked as solved
1 Replies
256 Views
When I call startMonitoringLocationPushesWithCompletion, the completion "callback" is never executed. This is what we have done to prepare for this service: We have the com.apple.developer.location.push in the entitlements file Our request to use the location push service has been approved We have enabled Location Push Service Extension in Certificates, Identifiers & Profiles of our app on developer.apple.com We have the push notification and location update capabilities The user has granted the app "Always" location access We have these purpose strings in our info.plist already: NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription We have the automatically generated location push service extension Here is the code that we use to test the service: #import <React/RCTLog.h> #import <CoreLocation/CoreLocation.h> #import "AppDelegate.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {   if (@available(iOS 15.0, *)) {     RCTLogInfo(@"Starting monitoring location pushes");     CLLocationManager *locationManager = [[CLLocationManager alloc] init];     [locationManager startMonitoringLocationPushesWithCompletion:^(NSData * _Nullable token, NSError * _Nullable error) {       RCTLogInfo(@"Completion called");       if (token) {         NSString *tokenString = [NSString stringWithFormat:@"%@", token];         RCTLogInfo(@"Token: %@", tokenString);       }       if (error){         RCTLogError(@"Error: %@", error);       }       RCTLogInfo(@"Completion ends %@ %@", token, error);     }];     RCTLogInfo(@"End monitoring location pushes");   } else {     RCTLogError(@"Incompatible iOS version");   } return YES; } The only logs: 2022-03-29 18:38:02.736615+0100 ***[yyy] [native] Starting monitoring location pushes 2022-03-29 18:38:02.738087+0100 ***[yyy] [native] End monitoring location pushes
Posted
by EricHo73.
Last updated
.