This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
Introduce Location Manager Utility and Optimize Background Telemetry #4115
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
When Mapbox telemetry is used in a host application that has background.location permissions AND
always
permissions granted by the user, the location manager utility will attempt to gather anonymous location data in the background to improve map quality. Previously, the Mapbox SDK did little to optimize background data collection for the case of stationary devices. Running location services in the background, even in a passive way, consumes resources and contributes to battery drain and background activity time of the host application in the iOS battery report.What's in this PR?
This change makes background data gathering more efficient by disabling standard location updates when the device has been stationary for at least five minutes. It also establishes region monitoring and significant location change monitoring so that if the device appears to be in motion again then background telemetry data collection can resume. All of this reduces the amount of time required for telemetry data collection to the time the device is in motion only. It also only applies to host apps that already run in the background and have the
always
location permission from their users.This also includes some changes to make the internal pause/resume API of the
MGLMapboxEvents
class less complex and autonomous. The side effects of the map view waking or sleeping are no longer required for mapbox events to work as intended.Addresses:
Subsumes:
cc @1ec5 @friedbunny
fyi @bleege @mick @camilleanne @willwhite