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
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
Post not yet marked as solved
1 Replies
124 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
by
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
by
Post not yet marked as solved
0 Replies
141 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
Post not yet marked as solved
0 Replies
160 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
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
by
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
by
Post not yet marked as solved
0 Replies
113 Views
Hello Team, We have an app that we use to track our drivers for delivery, if a driver reaches a geofence it triggers an alert back to the dispatcher that the driver has completed his drop and is ready to take the next one. The app connects to the backend once every few minutes to retrieve available orders. We are using significant location changes and run most of the calculations on the device. Issue is when the device reboots the app goes cold and we do not have any pings back to the server neither get any geofence breach notifications. Is there a way to do this? We anticipate this app to be on all of our employee devices(which we own). Thanks!
Posted
by
Post not yet marked as solved
0 Replies
116 Views
Hello All, Does anyone face issues getting trigger Geofence event or Significant Location update event is suspended and background state, I am facing an issue where the feature works most of the time and some time geofence and location updates do not trigger any callbacks, Sometimes I am getting triggered after 11 or 12 minutes later, most of the time, I get location updates in 2 or 3 minutes, for making it work again I need to start the application and put it back to a background/suspended state And the permission for access in the background is also "Always" Thanks
Posted
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
Post marked as solved
1 Replies
257 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
Post not yet marked as solved
1 Replies
268 Views
My question is how do you get ahold of the current user location title when clicking a button so that it can display the title inside the search bar. I know that by calling locationManager.requestLocation() inside my button it will redirect the user to current location but that is all know how to do. I've tried calling locationManager.location?.description but i had no luck.
Posted
by
Post not yet marked as solved
0 Replies
153 Views
I am trying to work out how to start updating locations when triggered by a CLRegion in iOS 15. The use case is that a user gets to a certain predefined starting point (determined by region monitoring) for a regular journey and then the app startUpdatingLocation, without need for user interaction. In my testing so far, if I call startUpdatingLocation from within didEnterRegion the updates stop within 10.
Posted
by
Post not yet marked as solved
1 Replies
301 Views
Hello, I was uploading new builds for 2 Apps (they have the Location Entitlements on info.plist) I've installed them on 3 different iPhones and they don't have the Location Permissions on Settings anymore: It stopped working last week, for newer builds, as well as with older builds which were proven to work When installing the same builds on TestFlight for Silicon MacBook, the laptop has setting to enable Location for this App .. so it shouldn't be a 'signing' or 'setup' conflict When I run a release build with xCode via USB to my phone, works correctly I had the TestFlight version installed long ago (i only clicked update to the last build). The location settings were on my Phone. The problem arose for the testers that installed any of our builds this last week When I uninstalled and installed it again, the location settings were gone for me too It's like that when our Apps go through TestFlight Servers, a failed build is provided to us. I'm happy to help solve this, thanks. Eze
Posted
by
Post not yet marked as solved
0 Replies
255 Views
Unexpected operation found. Details are below: Conditions and configurations used in the testing: "Background Modes" Capability with "Location updates" checked on Added the info.plist keys: NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationWhenInUseUsageDescription with description Monitoring for several beacon regions and invoking startMonitoringSignificantLocationChanges using core location API My app's location authorization status set 'Always' Added UserNotification in func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool , so that a notification could be triggered in AppDelegate method when an application is launched. How I tested Given the condition above applied, I have closed my application by force using "swiping up in the app-switcher screen" What I expected I have been convinced that "close-by-force" triggers the removal process of the target application(my app) from the memory. And it stays so until it is relaunched by the system given the specific location-related events - such as entering into registered beacon region or moving over 500-meter(significant locations changes).  What I actually found I have discovered that in some versions of iOS, specifically iOS 15.3 and iOS 15.3.1, my application was relaunched immediately and automatically as soon as the app was closed(close-by-force). No beacon enter or moving over 500-meter events are involved. This unexpected relaunching issue was not found in the other version of iOS. I have tested eleven devices that are using iOS 10.3.3 ~ 15.1. What I want to know I am wondering if this relaunching case in iOS 15.3 and 15.3.1 is an unexpected bug or not.  In addition, I also want to know why it is working differently between iOS versions. Thanks for your help in advance.
Post not yet marked as solved
1 Replies
241 Views
Hello All, Does anyone face issue getting trigger Geofence event or Significant Location update event is suspended and background state in IOS 15, I am facing an issue where the feature works most of the time and some time geofence and location updates do not trigger any callbacks, for making it work again I need to start the application and put it back to a background/suspended state And the permission for access in the background is also "Always" Thanks
Posted
by
Post not yet marked as solved
0 Replies
241 Views
Why locationManager did disconnect in this circumstance? Always after START -> STOP -> START service. locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBest; locationManager.distanceFilter = 5; // meters locationManager.allowsBackgroundLocationUpdates = YES; locationManager.pausesLocationUpdatesAutomatically = NO; if (@available(iOS 14.0, *)) {     if (locationManager.authorizationStatus == kCLAuthorizationStatusAuthorizedWhenInUse){       [locationManager startUpdatingLocation];     } else {       shouldStart = false; [locationManager requestWhenInUseAuthorization];     }   } else {     // Fallback on earlier versions   } --- resume log --- {"msg":"#sbim client arrow state changed", "clientKey":"it.trainingcamp.app", "entityClass":"Application", "oldArrowState":"ReceivingLocationInformation", "newArrowState":"RequestingLocationInformation", "dueToDeauthorization":0} client 'it.trainingcamp.app' authorized for location; starting shortly client 'it.trainingcamp.app' authorized for location; starting now, desiredAccuracy, -1.0, distanceFilter, 5.0, operatingMode 0, dynamicAccuracyReductionEnabled 0, allowsAlteredAccessoryLocations 0, activityType 0 [application<it.trainingcamp.app>:9023] Suspending task. Calculated state for application<it.trainingcamp.app>: running-suspended (role: None) Process runningboardd.34 Released SystemIsActive "application<it.trainingcamp.app>34-77-203313:Location subscription" age:00:00:31 id:51539648441 [System: SysAct] -CMSessionMgr- CMSessionMgrHandleApplicationStateChange: Client it.trainingcamp.app with pid '9023' is now Background Suspended. Background entitlement: YES ActiveLongFormVideoSession: NO WhitelistedLongFormVideoApp NO -CMSessionMgr- CMSessionMgrHandleApplicationStateChange: Sending stop command to it.trainingcamp.app with pid '9023' because client is background suspended and there is no AirPlay video session for it [application<it.trainingcamp.app>:9023] Setting process task state to: Suspended
Posted
by
Post not yet marked as solved
0 Replies
222 Views
My understanding is that when an app enters the background, the app will run for a period of time and eventually will be suspended, and while in the background can continue to run tasks. Then with no activity an app in the background will be suspended but remain in memory subject to the system purging it on low memory events. When the app is suspended it stops executing code. The user can terminate an app by swiping up from the Home Screen. When an app is suspended and purged or terminated by the user all objects including view controllers are removed from memory and cannot receive updates from the UIApplication object. An exception is region updates, which will be picked up by the appDelegate when the app is in the background, suspended or terminated, and will "activate" the app for processing the event. I also understand region objects are retained in memory regardless of the app's state. Thus on entering a region, the appDelegate can deal with the region entered in whatever state the app might be in. I'm working on an app that uses region monitoring. I have put the didEnterRegion and didExitRegion CLLocationManagerDelegate functions in the appDelegate, where I also set up and start location services. I have one MasterViewContoller for UI reporting enter/exit region activity and one NSObject class Comm that handles enter/exit events by sending off an http post. This Comm object is instantiated in the MasterviewController like this: let comm = Comm() and the MasterViewController is reference in appDelegate like this: var vc = MasterViewController() In appDelegate I have the didEnterRegion and didExitRegion functions: func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {       if region is CLCircularRegion { let identifier = region.identifier [NOTE: code here to issue a local notification for testing - this functions regardless of the app's state]           vc.processRegionEvent(regionid: identifier) comm.sendHttp(theid: identifier)       } } This works as expected so long as the app is not in the background or has been terminated - e.g. manually by the user or by the system for being in the background for a while. But once the app is terminated or goes to the background, neither the viewController or the Comm class consistently respond. Sometimes they respond and sometimes not - this is what I am trying to isolate and fix. It appears that even though the appDelegate "activates" and responds to region events, that doesn't mean the app and its objects are fully loaded and ready to respond to events and function calls. When using region monitoring, what is the preferred method to insure the relevant objects such as a viewController and other classes are instantiated and able to respond to region changes picked up by the appDelegate when the app is in the background or terminated? Is is necessary to put the entire code in appDelegate?
Posted
by
Post not yet marked as solved
0 Replies
247 Views
Hi, Our application needs to receive and process positions, even in background. The associated UIBackgroundMode is activated, and everything was working well until I updated a test tablet to 15.3.1. The application was switching to background (with position correctly feeds - as expected), but never to suspended. Now it keeps background mode for few seconds or minutes (GPS working at this moment) and then switches to suspended where no more events are triggered. Is there any recent changes on this subject that could explain ? (that's critical for our application)
Posted
by