Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios] Avoid the blue background location status bar
Browse files Browse the repository at this point in the history
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
  • Loading branch information
friedbunny committed Jan 23, 2016
1 parent 9cfe64a commit 77500e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Known issues:
- Made telemetry on/off setting available in-app. ([#3445](https://github.com/mapbox/mapbox-gl-native/pull/3445))
- Fixed an issue with users not being counted by Mapbox if they had disabled telemetry. ([#3495](https://github.com/mapbox/mapbox-gl-native/pull/3495))
- Fixed crash caused by MGLAnnotationImage with non-integer width or height ([#2198](https://github.com/mapbox/mapbox-gl-native/issues/2198))
- No longer triggers blue background location status bar when user has granted "when in use" permission. ([#3671](https://github.com/mapbox/mapbox-gl-native/issues/3671))

## iOS 3.0.1

Expand Down
25 changes: 18 additions & 7 deletions platform/ios/src/MGLMapboxEvents.m
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,24 @@ - (void)validateUpdatingLocation {
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;
}
}
}
Expand Down

0 comments on commit 77500e6

Please sign in to comment.