summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorJason Wray <jason@mapbox.com>2016-01-22 19:16:49 -0500
committerJason Wray <jason@mapbox.com>2016-01-25 14:59:38 -0500
commit9418f9a9870dc5b23c150fa9dc017e101582db30 (patch)
treef936063a212aa0943a10e5b2bac809eba7f9efbb /platform
parent2f86467586706d254fcbcb1c88657992214aefcd (diff)
downloadqtlocation-mapboxgl-9418f9a9870dc5b23c150fa9dc017e101582db30.tar.gz
[ios] Avoid the blue background location status bar
Apps with `whenInUse` location permission will show a blue status bar when they continue to use location services after leaving the foreground. This is worrying and to be avoided, so let's disable telemetry location services in this situation. Fixes #2945
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/src/MGLMapboxEvents.m25
1 files changed, 18 insertions, 7 deletions
diff --git a/platform/ios/src/MGLMapboxEvents.m b/platform/ios/src/MGLMapboxEvents.m
index 8aa790c41f..8138d29169 100644
--- a/platform/ios/src/MGLMapboxEvents.m
+++ b/platform/ios/src/MGLMapboxEvents.m
@@ -336,13 +336,24 @@ const NSTimeInterval MGLFlushInterval = 60;
if (self.paused) {
[self stopUpdatingLocation];
} else {
- CLAuthorizationStatus authStatus = [CLLocationManager authorizationStatus];
- if (authStatus == kCLAuthorizationStatusDenied ||
- authStatus == kCLAuthorizationStatusRestricted) {
- [self stopUpdatingLocation];
- } else if (authStatus == kCLAuthorizationStatusAuthorized ||
- authStatus == kCLAuthorizationStatusAuthorizedWhenInUse) {
- [self startUpdatingLocation];
+ switch ([CLLocationManager authorizationStatus]) {
+ case kCLAuthorizationStatusNotDetermined:
+ case kCLAuthorizationStatusRestricted:
+ case kCLAuthorizationStatusDenied:
+ [self stopUpdatingLocation];
+ break;
+ case kCLAuthorizationStatusAuthorized:
+ // Also handles kCLAuthorizationStatusAuthorizedAlways
+ [self startUpdatingLocation];
+ break;
+ case kCLAuthorizationStatusAuthorizedWhenInUse:
+ if (UIApplication.sharedApplication.applicationState == UIApplicationStateBackground) {
+ // Prevent blue status bar when app is not in foreground
+ [self stopUpdatingLocation];
+ } else {
+ [self startUpdatingLocation];
+ }
+ break;
}
}
}