I have been working on a feature whereby I need to notify the user via local notification once a vehicle is reaching its destination. Accuracy is important here as there are other destinations along the journey so region monitoring and significant change is not applicable after testing and finding that the notification sometimes triggered too late (i.e. after the user passed the destination). Background Location Update via the standard location update service meets this requirement and several testing confirms the approach. Location monitoring has been constant and notification was triggered when the destination is within a certain distance. To do this, I've turned on:Background Mode (Location Updates)Background Mode (Audio, AirPlay and Picture in Picture, for playing a custom alert when it reaches the destination)Code wise, I've implemented the standard location update service with the following: locationManager.distanceFilter = 10
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation
locationManager.activityType = CLActivityType.automotiveNavigation
locationManager.allowsBackgroundLocationUpdates = true
locationManager.pausesLocationUpdatesAutomatically = false
locationManager.requestWhenInUseAuthorization()A delegate in the AppDelegate has also been implemented for didUpdateLocation. Upon activating, the blue navigation status bar is also showing once I exit my App. Many tests has also affirm that all is working and working well.The Issue:Although everything looks good and ready for deploy, we are facing the problem of the background location update stopping after a prolong period of time (about 40 minutes to 2 hours) inconsistently. To test this further, I have also set the location update the night before, seeing the blue navigation bar when I exit, only to find the blue bar is gone when I woke up the next morning (Pretty extreme test, but desperate times call for desperate measures 😀). I have looked at various Apple documentation and other sources but have not found a reason for this stopping of the service. My best suspicion thus far is that this is something to do with how iOS stops or kills the App due to prolong inactivities with the App. I have ruled out battery life issue as I have been plugged in at times when this occurs. Resource-wise is also less likely since to control the test, I do close off other apps before testing. My question therefore is, with allowBackgroundLocationUpdates set to true, and pausesLocationUpdatesAutomatically set to false. Is there anything else that I might be missing here that is causing this erratic behaviour of the background location update. If it's an issue of inactivity or lack of significant location change (for the case of when I set it overnight), what can be done to ensure a more consistent keep-alive of the service. Thank you for reading this long post to a question, just wanted to make sure I explained the situation clearly. Hope to get some assistance here! Cheers!