0

I'm building an application which has the following requirements:

  1. There are X number of locations that the user can check-in or check-out from.
  2. Whenever the user enters any of the X locations, I need to call some backend APIs.
  3. Whenever the user exits any of the X locations, I need to call the same backend APIs.
  4. This needs to work even if the user has the app in the background, foreground or hard-closed.
  5. 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.
  6. 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?

BunkBedNoob
  • 367
  • 1
  • 4
  • 15
  • You can use CLCircularRegions for entry/exit notification but nothing is going to work when the app is hard closed. If the user kills the app, it is dead. – Paulw11 Mar 26 '17 at 08:22
  • Thanks @Paulw11, is there any way I can restart the application when the app is hard-closed other than sending the user a Push Notification Message? – BunkBedNoob Mar 26 '17 at 08:26
  • No. iOS puts the user in charge. If they kill an app it will stay dead – Paulw11 Mar 26 '17 at 08:57
  • Actually, according to the second answer on [this question](http://stackoverflow.com/questions/37450524/ios-getting-location-updates-when-app-terminated-without-using-significantchange) a region entry will relaunch a terminated app, so perhaps some testing is required. – Paulw11 Mar 26 '17 at 09:09
  • @Paulw11 The region Entry/Exit callbacks will wake up your app for 10 seconds before sending it into background. You can use this time to send a `UILocalNotification` so that the user opens the app – firecast Mar 26 '17 at 10:05
  • @firecast the question is whether this still happens after the user force terminates the app. – Paulw11 Mar 26 '17 at 10:06
  • @Paulw11 the OS will wake up your app. I've been part of an SDK that heavily relies on Geofence and iBeacon region monitoring to wake up the app. This however requires the app to have Always Location permission – firecast Mar 26 '17 at 10:10
  • Thanks @firecast, I will look into it today. I will try and code this and test it today. If it happens to work, I'll post the solution here too. – BunkBedNoob Mar 26 '17 at 17:34

0 Answers0