Skip to content

Commit

Permalink
feat(ios): stop requesting location permissions in showsUserLocation
Browse files Browse the repository at this point in the history
Resolves #4166
BREAKING CHANGE: Requesting location permissions manually is now needed for showsUserLocation.
  • Loading branch information
monholm committed May 18, 2022
1 parent 849b1bc commit 1d0e381
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 12 deletions.
4 changes: 0 additions & 4 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ $ (cd ios && pod install)
$ npx pod-install
```

### Set the usage description property

The app's `Info.plist` file must contain a `NSLocationWhenInUseUsageDescription` with a user-facing purpose string explaining clearly and completely why your app needs the location, otherwise Apple will reject your app submission.

### Enabling Google Maps

If you want to enable Google Maps on iOS, obtain the Google API key and edit your `AppDelegate.m` as follows:
Expand Down
2 changes: 1 addition & 1 deletion docs/mapview.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
| `mapType` | `String` | `"standard"` | The map type to be displayed. <br/><br/> - standard: standard road map (default)<br/> - none: no map **Note** Not available on MapKit<br/> - satellite: satellite view<br/> - hybrid: satellite view with roads and points of interest overlayed<br/> - terrain: topographic view<br/> - mutedStandard: more subtle, makes markers/lines pop more (iOS 11.0+ only)
| `customMapStyle` | `Array` | | Adds custom styling to the map component. See [README](https://github.com/react-native-maps/react-native-maps#customizing-the-map-style) for more information.
| `userInterfaceStyle` | 'light' \| 'dark' | | Sets the map to the style selected. Default is whatever the system settings is. **Note:** iOS Maps only (aka MapKit).
| `showsUserLocation` | `Boolean` | `false` | If `true` the app will ask for the user's location. **NOTE**: You need to add `NSLocationWhenInUseUsageDescription` key in Info.plist to enable geolocation, otherwise it is going to *fail silently*! You will also need to add an explanation for why you need the users location against `NSLocationWhenInUseUsageDescription` in Info.plist. Otherwise Apple may reject your app submission.
| `showsUserLocation` | `Boolean` | `false` | If `true` the users location will be shown on the map. **NOTE**: You need runtime location permissions prior to setting this to true, otherwise it is going to *fail silently*! Checkout the excellent [react-native-permissions](https://github.com/zoontek/react-native-permissions) for this.
| `userLocationPriority` | 'balanced'\|'high'\|'low'\|'passive' | 'high' | Set power priority of user location tracking. See [Google APIs documentation](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html). **Note:** Android only.
| `userLocationUpdateInterval` | `Number` | 5000 | Interval of user location updates in milliseconds. See [Google APIs documentation](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html). **Note:** Android only.
| `userLocationFastestInterval` | `Number` | 5000 | Fastest interval the application will actively acquire locations. See [Google APIs documentation](https://developers.google.com/android/reference/com/google/android/gms/location/LocationRequest.html). **Note:** Android only.
Expand Down
7 changes: 0 additions & 7 deletions ios/AirMaps/AIRMap.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ - (void)updateZoomEnabled;
@implementation AIRMap
{
UIView *_legalLabel;
CLLocationManager *_locationManager;
BOOL _initialRegionSet;
BOOL _initialCameraSet;

Expand Down Expand Up @@ -350,12 +349,6 @@ - (NSArray *)getMapBoundaries
- (void)setShowsUserLocation:(BOOL)showsUserLocation
{
if (self.showsUserLocation != showsUserLocation) {
if (showsUserLocation && !_locationManager) {
_locationManager = [CLLocationManager new];
if ([_locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[_locationManager requestWhenInUseAuthorization];
}
}
super.showsUserLocation = showsUserLocation;
}
}
Expand Down

0 comments on commit 1d0e381

Please sign in to comment.