Skip to content
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

Merged
merged 1 commit into from
Feb 26, 2016

Conversation

boundsj
Copy link
Contributor

@boundsj boundsj commented Feb 26, 2016

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

@boundsj boundsj added iOS Mapbox Maps SDK for iOS telemetry Integration with Mapbox Telemetry libraries in progress labels Feb 26, 2016
@boundsj boundsj self-assigned this Feb 26, 2016
@boundsj boundsj added this to the ios-v3.2.0 milestone Feb 26, 2016

@protocol MGLLocationManagerUtilityDelegate;

@interface MGLLocationManagerUtility : NSObject <CLLocationManagerDelegate>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call this MGLLocationManager or MGLTelemetryLocationManager, since it functions like a replacement for CLLocationManager rather than a complement to it.

@1ec5 1ec5 added the refactor label Feb 26, 2016
#4115

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.
@willwhite
Copy link

👏

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
iOS Mapbox Maps SDK for iOS refactor telemetry Integration with Mapbox Telemetry libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants