Will iOS Region Monitoring Call Didenterregion on My App If My App Is in a Terminated State

CLLocationManager Region Monitoring: Detect Arrival in Suspended State

Any location update/monitoring requires it's location manager to be configured properly so that it can work to the best to provide the desired location update. It's important to check some point when doing background location update:

1. Check background modes of location updates and background fetch should be enable

2. Check 'Location Always Usage Description' and 'Location When in Use Usage Description' in the Info.plist should be provided

3. Check if you want to pause in between location update - if yes then you need to provide activity type so that location manager can determine best way to pause location update for you

4. Check if you want to apply distance filter - you want user(device) to move some minimum amount for location manager to send updated location

5. Check if you want desired accuracy- This may cause power drain for certain accuracy type

In your code I can see location manager is configured with some of the parameter but missing accuracy and distance filter for background mode.

   locationManager.allowsBackgroundLocationUpdates = true
locationManager.pausesLocationUpdatesAutomatically = false
locationManager.activityType = .otherNavigation

Also, if you see pause location update property in Apple doc it says:

For apps that have in-use authorization, a pause to location updates
ends access to location changes until the app is launched again and
able to restart those updates. If you do not wish location updates to
stop entirely, consider disabling this property and changing location
accuracy to kCLLocationAccuracyThreeKilometers when your app moves to
the background. Doing so allows you to continue receiving location
updates in a power-friendly manner.

Essentially it tells that if you want disable pause then you have to keep accuracy level (kCLLocationAccuracyThreeKilometers). Which I guess is missing in your approach.

Also, you can check this link which actually starts background task and then starts location manager monitoring inside the background task.
Hope it helps.

startMonitoringForRegion is not calling didEnterRegion if the app is started within the region

I don't think you can do that.

But, you can get the current location and check if it's inside the region you're specifying yourself. CLCircularRegion has a containsCoordinate: method for this.

Will geofencing events be called if the app is terminated in iOS 11?

After running many tests, I can confirm that Geofence Events are called, even when the app is terminated (swipe up). However, the user must have authorized location to be used when the app isn't running, and other background location functions, such as didUpdateLocation will not be called.



Related Topics



Leave a reply



Submit