diff --git a/geolocator/CHANGELOG.md b/geolocator/CHANGELOG.md index 8ac1f3531..904f6ddfe 100644 --- a/geolocator/CHANGELOG.md +++ b/geolocator/CHANGELOG.md @@ -1,3 +1,7 @@ +## 10.1.1 + +- Adds a description to the README on how to add the `BYPASS_PERMISSION_LOCATION_ALWAYS` preprocessor to bypass the need for adding the `NSLocationAlwaysUsageDescription` to the `Info.plist`. + ## 10.1.0 - Includes `altitudeAccuracy` and `headingAccuracy` in `Position`. diff --git a/geolocator/README.md b/geolocator/README.md index 78e462618..0389c8e9b 100644 --- a/geolocator/README.md +++ b/geolocator/README.md @@ -76,16 +76,32 @@ Starting from Android 10 you need to add the `ACCESS_BACKGROUND_LOCATION` permis
iOS -On iOS you'll need to add the following entries to your Info.plist file (located under ios/Runner) in order to access the device's location. Simply open your Info.plist file and add the following (make sure you update the description so it is meaningfull in the context of your App): +On iOS you'll need to add the following entry to your Info.plist file (located under ios/Runner) in order to access the device's location. Simply open your Info.plist file and add the following (make sure you update the description so it is meaningfull in the context of your App): ``` xml NSLocationWhenInUseUsageDescription This app needs access to location when open. -NSLocationAlwaysUsageDescription -This app needs access to location when in the background. ``` -If you would like to receive updates when your App is in the background, you'll also need to add the Background Modes capability to your XCode project (Project > Signing and Capabilities > "+ Capability" button) and select Location Updates. Be careful with this, you will need to explain in detail to Apple why your App needs this when submitting your App to the AppStore. If Apple isn't satisfied with the explanation your App will be rejected. +If you don't need to receive updates when your app is in the background, then add a compiler flag as follows: in XCode, click on Pods, choose the Target 'geolocator_apple', choose Build Settings, in the search box look for 'Preprocessor Macros' then add the `BYPASS_PERMISSION_LOCATION_ALWAYS=1` flag. +Setting this flag prevents your app from requiring the `NSLocationAlwaysAndWhenInUseUsageDescription` entry in Info.plist, and avoids questions from Apple when submitting your app. + +You can also have this flag be set automatically by adding to the `Podfile` for your application: +```agsl +post_install do |installer| + installer.pods_project.targets.each do |target| + if target.name == "geolocator_apple" + target.build_configurations.each do |config| + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'BYPASS_PERMISSION_LOCATION_ALWAYS=1'] + end + end + end +end +``` + +If you do want to receive updates when your App is in the background (or if you don't bypass the permission request as described above) then you'll need to: +* Add the Background Modes capability to your XCode project (Project > Signing and Capabilities > "+ Capability" button) and select Location Updates. Be careful with this, you will need to explain in detail to Apple why your App needs this when submitting your App to the AppStore. If Apple isn't satisfied with the explanation your App will be rejected. +* Add an `NSLocationAlwaysAndWhenInUseUsageDescription` entry to your Info.plist (use `NSLocationAlwaysUsageDescription` if you're targeting iOS <11.0) When using the `requestTemporaryFullAccuracy({purposeKey: "YourPurposeKey"})` method, a dictionary should be added to the Info.plist file. ```xml diff --git a/geolocator/example/ios/Podfile b/geolocator/example/ios/Podfile index f7d6a5e68..837295fed 100644 --- a/geolocator/example/ios/Podfile +++ b/geolocator/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '9.0' +# platform :ios, '12.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' @@ -34,5 +34,11 @@ end post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) + # To bypass the permission check for background location updates, uncomment the following lines + #if target.name == "geolocator_apple" + # target.build_configurations.each do |config| + # config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'BYPASS_PERMISSION_LOCATION_ALWAYS=1'] + # end + #end end end diff --git a/geolocator/pubspec.yaml b/geolocator/pubspec.yaml index 3494330da..8b5d6aa10 100644 --- a/geolocator/pubspec.yaml +++ b/geolocator/pubspec.yaml @@ -2,7 +2,7 @@ name: geolocator description: Geolocation plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API for generic location (GPS etc.) functions. repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator issue_tracker: https://github.com/baseflow/flutter-geolocator/issues?q=is%3Aissue+is%3Aopen -version: 10.1.0 +version: 10.1.1 environment: sdk: ">=2.15.0 <4.0.0" diff --git a/geolocator_apple/CHANGELOG.md b/geolocator_apple/CHANGELOG.md index bc5dd5b57..67c373776 100644 --- a/geolocator_apple/CHANGELOG.md +++ b/geolocator_apple/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.3.6 + +* Adds option to bypass the request for permission to update location in the background (which can attract scrutiny from Apple upon app submission). To bypass, set the preprocessor macro `BYPASS_PERMISSION_LOCATION_ALWAYS` to 1 in XCode + ## 2.3.5 * Previously the plugin filtered out negative values for heading and/or heading accuracy. Now the plugin is returning the heading and/or the heading accuracy even if the they have a negative value (invalid), so that the developer can use it and decide what to do with it. diff --git a/geolocator_apple/example/ios/Podfile b/geolocator_apple/example/ios/Podfile index e8a87fb96..87a77d50e 100644 --- a/geolocator_apple/example/ios/Podfile +++ b/geolocator_apple/example/ios/Podfile @@ -41,5 +41,11 @@ end post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) + # To bypass the permission check for background location updates, uncomment the following lines + #if target.name == "geolocator_apple" + # target.build_configurations.each do |config| + # config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'BYPASS_PERMISSION_LOCATION_ALWAYS=1'] + # end + #end end end diff --git a/geolocator_apple/ios/Classes/Handlers/PermissionHandler.m b/geolocator_apple/ios/Classes/Handlers/PermissionHandler.m index 2b216e38d..42f4394ae 100644 --- a/geolocator_apple/ios/Classes/Handlers/PermissionHandler.m +++ b/geolocator_apple/ios/Classes/Handlers/PermissionHandler.m @@ -72,9 +72,11 @@ - (void) requestPermission:(PermissionConfirmation)confirmationHandler if ([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"] != nil) { [locationManager requestWhenInUseAuthorization]; } +#if !BYPASS_PERMISSION_LOCATION_ALWAYS else if ([self containsLocationAlwaysDescription]) { [locationManager requestAlwaysAuthorization]; } +#endif #endif else { if (self.errorHandler) { @@ -89,6 +91,7 @@ - (void) requestPermission:(PermissionConfirmation)confirmationHandler } } +#if !BYPASS_PERMISSION_LOCATION_ALWAYS - (BOOL) containsLocationAlwaysDescription { BOOL containsAlwaysDescription = NO; if (@available(iOS 11.0, *)) { @@ -99,6 +102,7 @@ - (BOOL) containsLocationAlwaysDescription { ? containsAlwaysDescription : [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"] != nil; } +#endif - (void) locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status { if (status == kCLAuthorizationStatusNotDetermined) { diff --git a/geolocator_apple/pubspec.yaml b/geolocator_apple/pubspec.yaml index fa4224dd3..9f18896b9 100644 --- a/geolocator_apple/pubspec.yaml +++ b/geolocator_apple/pubspec.yaml @@ -2,7 +2,7 @@ name: geolocator_apple description: Geolocation Apple plugin for Flutter. This plugin provides the Apple implementation for the geolocator. repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator_apple issue_tracker: https://github.com/baseflow/flutter-geolocator/issues?q=is%3Aissue+is%3Aopen -version: 2.3.5 +version: 2.3.6 environment: sdk: ">=2.15.0 <4.0.0"