Inconsistency in Region Montoring

We have developed a construction project application in iOS, where a project manager can invite users to work in that construction project. Whenever the linked users/project manager of a particular project reaches the project site location we send them notifications to tell them to watch site safety videos before entering the site. If the users have seen those videos then we don’t send these notifications again to those users on next time entering the project location. This is all working good.


Now we have added a new functionality in this app with which attendance of these users can be marked as they enter in the project site location. For this we have used Geofencing feature, we create geofences for nearby projects of user location, as soon as the user enters a particular project geofence we mark him as checked in (with entry timing) and on exiting from the geofence, the user gets marked as checked out(with exit timings). This works 100% if we keep the iOS app in background (if app is kept open in recent apps), but it does NOT ALWAYS work when the app is closed (if the app is removed from recent apps). We have tried Significant Region monitoring as well, but not getting any consistency in the results for all the users.


So our question here is that does iOS support this GPS call when app is closed, means can we execute any code in the app when app is closed (removed from recent apps)? If yes then to what accuracy because our GPS code call does not work 100% when the app is closed?

Generally speaking, when the user explicitly terminates an app, that app is not launched again in the background.


There are some exceptions to this, and location monitoring is one off them. However, from what you are describing, the significant change location service may not be. There are different location services, and it sounds like you may need a different one enabled at the cost of decreased battery life.


Perhaps someone with with more knowledge on this can help.

The general rule is, if a user swipes an app away, it is taken as a signal that they don't want that app to be running in any form anymore, and the app will no longer be launched based on a background service.


Region Monitoring is an exception to that, as in, your app will be relaunched even after user terminates it. Significant Location Change is not in this exception, and won't relaunch your app.


It is hard to tell what is causing your app to not be relaunched without knowing more details. Assuming you have read the documentation and followed the steps correctly, here are some gotchas I can think of:

- you mentioned GPS. Region Monitoring does not use GPS. It uses location data obtained via WiFi access points and mobile phone towers. To use GPS, your app must also be using the Standard Location Service (via startUpdatingLocations call). If you are indeed using that, once the app is terminated, you will no longer receive GPS updates and Region Monitoring will depend solely on alternative sources, which will significantly decrease your accuracy

- you also mentioned the Significant Location Change service. This will also stop once your app is terminated by the user.

- how remote are these construction sites? In urban areas where there is lots of WiFi coverage, and multiple phone towers, the accuracy of the location is much higher than a remote urban area where there might be even limited mobile coverage. In those cases your accuracy will be over a kilometer. Then how large are these regions. A region only a few hundred meters across will likely fail to register if your accuracy is 1400 meters.

- how are you testing? You can expect to receive the appropriate region entered or region exited notification within 3 to 5 minutes on average. A typical failure is to test too fast, and run into the limits where the system won't relaunch your app over and over. If you kill the app, enter a region, kill it again, etc., the system may not be relaunching the app for more than once within a certain period

- how big are your regions and how fast do you expect the notifications to come? Region events may not happen immediately after a region boundary is crossed. To prevent spurious notifications, iOS doesn’t deliver region notifications until certain threshold conditions are met. Specifically, the user’s location must cross the region boundary, move away from the boundary by a minimum distance, and remain at that minimum distance for at least 20 seconds before the notifications are reported.


Hopefully these points will ring a bell for you to pinpoint the cause for the issue.

Does not the Core Location documentation say that the Significant Location Change Monitoring Service will relaunch a properly configured app when a location event occurs, even if terminated by the user? "The significant location change service delivers events normally while an app is running in the foreground or background. For a terminated iOS app, this service relaunches the app to deliver events. Use of this service requires “Always” authorization from the user." From: Using Location Services in the Background https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/cl/CLLocationManager

Both region monitoring and significant location changes are relaunching my application from killed state. This feature was disabled in one iOS release (iOS 7.1 i think) but later Apple enabled it back. Its working perfectly in my application.

Inconsistency in Region Montoring
 
 
Q