I'm building an application which has the following requirements:
- There are X number of locations that the user can check-in or check-out from.
- Whenever the user enters any of the X locations, I need to call some backend APIs.
- Whenever the user exits any of the X locations, I need to call the same backend APIs.
- This needs to work even if the user has the app in the background, foreground or hard-closed.
- The X number of locations can change from time-to-time but it is okay to be updated anytime the application can call a backend API to update them.
- The locations have a minimum geofence radius of 100 meter.
I've searched for various solutions to do this. The first approach was to track location when the app is open only using startUpdatingLocation()
but it fails Requirement 4. The second approach was to track location with startMonitoringSignificantLocationChanges()
but it has significant discrepancies when a user enters or exits an area i.e. sometimes it doesn't catch a check-in or check-out so it fails Requirement 2 & 3.
The only thing left to try is region monitoring and I'm wondering whether it can satisfy all of the above arguments. I also couldn't find much documentation of how best to approach this problem. Can someone point me in the right direction, please?