diff --git a/permission_handler_apple/CHANGELOG.md b/permission_handler_apple/CHANGELOG.md index f800cf7b..3ceb4430 100644 --- a/permission_handler_apple/CHANGELOG.md +++ b/permission_handler_apple/CHANGELOG.md @@ -1,7 +1,11 @@ +## 9.0.4 + +* Add flag inside `UserDefaults` to save whether locationAlways has already been requested and prevent further requests, which would be left unanswered by the system. + ## 9.0.3 * Ensures a request for `locationAlways` permission returns a result unblocking the permission request and preventing the `ERROR_ALREADY_REQUESTING_PERMISSIONS` error for subsequent permission request. ## 9.0.2 -* Moves Apple implementation into its own package. \ No newline at end of file +* Moves Apple implementation into its own package. diff --git a/permission_handler_apple/ios/Classes/strategies/LocationPermissionStrategy.m b/permission_handler_apple/ios/Classes/strategies/LocationPermissionStrategy.m index cffa1976..6300346a 100644 --- a/permission_handler_apple/ios/Classes/strategies/LocationPermissionStrategy.m +++ b/permission_handler_apple/ios/Classes/strategies/LocationPermissionStrategy.m @@ -7,6 +7,8 @@ #if PERMISSION_LOCATION +NSString *const UserDefaultPermissionRequestedKey = @"org.baseflow.permission_handler_apple.permission_requested"; + @interface LocationPermissionStrategy () - (void) receiveActivityNotification:(NSNotification *)notification; @end @@ -38,8 +40,12 @@ - (ServiceStatus)checkServiceStatus:(PermissionGroup)permission { - (void)requestPermission:(PermissionGroup)permission completionHandler:(PermissionStatusHandler)completionHandler { PermissionStatus status = [self checkPermissionStatus:permission]; if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorizedWhenInUse && permission == PermissionGroupLocationAlways) { - // don't do anything and continue requesting permissions - } else if (status != PermissionStatusDenied) { + BOOL alreadyRequested = [[NSUserDefaults standardUserDefaults] boolForKey:UserDefaultPermissionRequestedKey]; // check if already requested the permantent permission + if(alreadyRequested) { + completionHandler(status); + return; + } + } else if (status != PermissionStatusDenied) { // handles undetermined always permission and denied whenInUse permission completionHandler(status); return; } @@ -59,6 +65,7 @@ - (void)requestPermission:(PermissionGroup)permission completionHandler:(Permiss if ([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationAlwaysUsageDescription"] != nil) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveActivityNotification:) name:UIApplicationDidBecomeActiveNotification object:nil]; [_locationManager requestAlwaysAuthorization]; + [[NSUserDefaults standardUserDefaults] setBool:TRUE forKey:UserDefaultPermissionRequestedKey]; } else { [[NSException exceptionWithName:NSInternalInconsistencyException reason:@"To use location in iOS8 you need to define NSLocationAlwaysUsageDescription in the app bundle's Info.plist file" userInfo:nil] raise]; } diff --git a/permission_handler_apple/ios/permission_handler_apple.podspec b/permission_handler_apple/ios/permission_handler_apple.podspec index 98894a3a..ff30cd90 100644 --- a/permission_handler_apple/ios/permission_handler_apple.podspec +++ b/permission_handler_apple/ios/permission_handler_apple.podspec @@ -3,7 +3,7 @@ # Pod::Spec.new do |s| s.name = 'permission_handler_apple' - s.version = '9.0.2' + s.version = '9.0.4' s.summary = 'Permission plugin for Flutter.' s.description = <<-DESC Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions. diff --git a/permission_handler_apple/pubspec.yaml b/permission_handler_apple/pubspec.yaml index c0bb58f9..16206f77 100644 --- a/permission_handler_apple/pubspec.yaml +++ b/permission_handler_apple/pubspec.yaml @@ -1,6 +1,6 @@ name: permission_handler_apple description: Permission plugin for Flutter. This plugin provides the iOS API to request and check permissions. -version: 9.0.3 +version: 9.0.4 homepage: https://github.com/baseflow/flutter-permission-handler environment: