I am working on an application that requires real-time location tracking soo. I use startMonitoringSignificantLocationChanges , and everything works fine on my iOS 10 simulator, even when the application is disabled by the user from the application switcher. I use the freeway-drive option when debugging using a simulator so that the location changes.
But for the iOS 11 simulator: When the application is in the background or foreground, the server is updated with the location of users in real time, but when the application forcibly shuts down, this does not happen.
The server does not receive the updated location, and I even set a breakpoint in didFinishLaunching and used the wait for executable to be launched parameter to check if I have a callback, but I am not for iOS 11 and am doing it for iOS 10.
I also updated info.plist with the appropriate values that are required for iOS 11, and confirmed that I grant "always" permission. I am using singleton for a location manager object using code:
func setupLocationManager(){ locationManager = CLLocationManager() locationManager.delegate = self locationManager.pausesLocationUpdatesAutomatically = false locationManager.allowsBackgroundLocationUpdates = true locationManager.requestAlwaysAuthorization() locationManager.distanceFilter = 100.0 locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters locationManager.startMonitoringSignificantLocationChanges() locationManager.startUpdatingLocation() }
And in the application delegate:
if let _ = launchOptions?[UIApplicationLaunchOptionsKey.location] { ChatSocketHelper.sharedInstance.socket.on("connect") { data, ack in if let coordinate = LocationManager.shared.currentLocation?.coordinate{ ChatSocketHelper.sharedInstance.updateLocation([coordinate.longitude, coordinate.latitude]) } } }
And in the delegate’s doing:
extension LocationManager : CLLocationManagerDelegate{ func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { guard let locationObject = locations.last else {return}
Is this a known issue with iOS 11 that the location is broken when the force is killed by the user? Since I searched a bit and found similar problems for bluetooth, but nothing significant for location changes otherwise.
For example, this link.
Edit : this one also reports that the updates are “slower”, but I am not getting the updates at all.