I'm developing an ios app for a private sector company, the app is required to be working all the time to track the user's location and upload it to the server.
so we used core location to get the users locations frequently, but it's not working very well or as promised because the app is being killed after less than one minute when the app enters to the background on some devices and will take up to 10 minutes on other devices even if the authorization is set to always.
location settings used in the app:
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
locationManager.requestAlwaysAuthorization()
locationManager.allowsBackgroundLocationUpdates = true
locationManager.pausesLocationUpdatesAutomatically = false
locationManager.showsBackgroundLocationIndicator = true
so is there any settings missing or do we have settings on the device to make sure the app works all the time unless the user closed by it itself? and does having iOS Developer Enterprise Program can help any in any way? thank you,
This is normal behavior. The fact that you have background mode doesn't mean that application will work forever in background. It means, the following:
When the system launches your app, use the launch options dictionary passed to the application(:willFinishLaunchingWithOptions:) and application(:didFinishLaunchingWithOptions:) methods to determine whether your app was launched to handle a location update. This dictionary contains the location key when the app is launched because of location services. Create a new CLLocationManager object, configure it with a delegate, and start location services again to receive the update.
Having distribution certificate might help, because might take some advantages of the private api (you don't need to pass Apple review in case of Enterprise distribution). But you should always remember that private API may lead you to unexpected headache.
I believe that careful reading of Background Execution and Handling Location Events in background documentation will bring you a better solution.