From f0878ba4585cd78834823e4ad1b17b3a2178f24d Mon Sep 17 00:00:00 2001 From: Sebastian Roth Date: Mon, 12 Feb 2024 23:17:19 +0800 Subject: [PATCH 1/3] Fix/1174 background refresh status (#1176) * Update project files * Add a new background refresh permission check for iOS * versions * cleanups * version bumps * missing constants --- permission_handler/CHANGELOG.md | 6 +++ permission_handler/pubspec.yaml | 6 +-- .../PermissionConstants.java | 1 + .../example/lib/main.dart | 3 +- permission_handler_android/pubspec.yaml | 2 +- permission_handler_apple/CHANGELOG.md | 4 ++ .../ios/Classes/PermissionHandlerEnums.h | 3 +- .../ios/Classes/PermissionManager.h | 1 + .../ios/Classes/PermissionManager.m | 2 + .../strategies/BackgroundRefreshStrategy.h | 17 +++++++++ .../strategies/BackgroundRefreshStrategy.m | 38 +++++++++++++++++++ permission_handler_apple/pubspec.yaml | 4 +- .../CHANGELOG.md | 4 ++ .../lib/src/permissions.dart | 5 +++ .../pubspec.yaml | 2 +- .../test/src/permissions_test.dart | 15 ++++++-- .../windows/permission_constants.h | 3 +- 17 files changed, 102 insertions(+), 14 deletions(-) create mode 100644 permission_handler_apple/ios/Classes/strategies/BackgroundRefreshStrategy.h create mode 100644 permission_handler_apple/ios/Classes/strategies/BackgroundRefreshStrategy.m diff --git a/permission_handler/CHANGELOG.md b/permission_handler/CHANGELOG.md index 1c252ec59..070b194c9 100644 --- a/permission_handler/CHANGELOG.md +++ b/permission_handler/CHANGELOG.md @@ -1,3 +1,9 @@ +## 11.3.0 + +* Adds a new permission `Permission.backgroundRefresh` to check the background refresh permission status via: + * Updates `permission_handler_apple` dependency to version 9.1.5. + * Updates `permission_handler_platform_interface` dependency to version 3.11.6. + ## 11.2.1 * Adds `PermissionGroup.photosAddOnly` to the README. diff --git a/permission_handler/pubspec.yaml b/permission_handler/pubspec.yaml index 8d497272b..c6be8ee07 100644 --- a/permission_handler/pubspec.yaml +++ b/permission_handler/pubspec.yaml @@ -2,7 +2,7 @@ name: permission_handler description: Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions. repository: https://github.com/baseflow/flutter-permission-handler issue_tracker: https://github.com/Baseflow/flutter-permission-handler/issues -version: 11.2.1 +version: 11.3.0 environment: @@ -26,10 +26,10 @@ dependencies: sdk: flutter meta: ^1.7.0 permission_handler_android: ^12.0.3 - permission_handler_apple: ^9.3.0 + permission_handler_apple: ^9.4.0 permission_handler_html: ^0.1.1 permission_handler_windows: ^0.2.1 - permission_handler_platform_interface: ^4.1.0 + permission_handler_platform_interface: ^4.2.0 dev_dependencies: flutter_lints: ^1.0.4 diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java index 6065a8031..841595e6a 100644 --- a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java +++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java @@ -61,6 +61,7 @@ final class PermissionConstants { static final int PERMISSION_GROUP_CALENDAR_WRITE_ONLY = 36; static final int PERMISSION_GROUP_CALENDAR_FULL_ACCESS = 37; static final int PERMISSION_GROUP_ASSISTANT = 38; + static final int PERMISSION_GROUP_BACKGROUND_REFRESH = 39; @Retention(RetentionPolicy.SOURCE) @IntDef({ diff --git a/permission_handler_android/example/lib/main.dart b/permission_handler_android/example/lib/main.dart index 8fb6d53b1..9d1252b97 100644 --- a/permission_handler_android/example/lib/main.dart +++ b/permission_handler_android/example/lib/main.dart @@ -42,7 +42,8 @@ class _PermissionHandlerWidgetState extends State { permission != Permission.bluetooth && permission != Permission.appTrackingTransparency && permission != Permission.criticalAlerts && - permission != Permission.assistant; + permission != Permission.assistant && + permission != Permission.backgroundRefresh; }) .map((permission) => PermissionWidget(permission)) .toList()), diff --git a/permission_handler_android/pubspec.yaml b/permission_handler_android/pubspec.yaml index 34616ea54..68dec9387 100644 --- a/permission_handler_android/pubspec.yaml +++ b/permission_handler_android/pubspec.yaml @@ -18,7 +18,7 @@ flutter: dependencies: flutter: sdk: flutter - permission_handler_platform_interface: ^4.1.0 + permission_handler_platform_interface: ^4.2.0 dev_dependencies: flutter_lints: ^1.0.4 diff --git a/permission_handler_apple/CHANGELOG.md b/permission_handler_apple/CHANGELOG.md index ebeafb13c..1f865286f 100644 --- a/permission_handler_apple/CHANGELOG.md +++ b/permission_handler_apple/CHANGELOG.md @@ -1,3 +1,7 @@ +## 9.4.0 + +* Adds a new permission `Permission.backgroundRefresh` to check the background refresh permission status. + ## 9.3.1 * Updates plist key from `NSPhotoLibraryUsageDescription` to `NSPhotoLibraryAddUsageDescription`. diff --git a/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h b/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h index 015f52d2b..90ef59c56 100644 --- a/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h +++ b/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h @@ -162,7 +162,8 @@ typedef NS_ENUM(int, PermissionGroup) { PermissionGroupSensorsAlways, PermissionGroupCalendarWriteOnly, PermissionGroupCalendarFullAccess, - PermissionGroupAssistant + PermissionGroupAssistant, + PermissionGroupBackgroundRefresh }; typedef NS_ENUM(int, PermissionStatus) { diff --git a/permission_handler_apple/ios/Classes/PermissionManager.h b/permission_handler_apple/ios/Classes/PermissionManager.h index abaab28af..4118ff83d 100644 --- a/permission_handler_apple/ios/Classes/PermissionManager.h +++ b/permission_handler_apple/ios/Classes/PermissionManager.h @@ -11,6 +11,7 @@ #import "AudioVideoPermissionStrategy.h" #import "AppTrackingTransparencyPermissionStrategy.h" +#import "BackgroundRefreshStrategy.h" #import "BluetoothPermissionStrategy.h" #import "ContactPermissionStrategy.h" #import "EventPermissionStrategy.h" diff --git a/permission_handler_apple/ios/Classes/PermissionManager.m b/permission_handler_apple/ios/Classes/PermissionManager.m index c4d9548d8..7ce972f05 100644 --- a/permission_handler_apple/ios/Classes/PermissionManager.m +++ b/permission_handler_apple/ios/Classes/PermissionManager.m @@ -149,6 +149,8 @@ + (id)createPermissionStrategy:(PermissionGroup)permission { return [CriticalAlertsPermissionStrategy new]; case PermissionGroupAssistant: return [AssistantPermissionStrategy new]; + case PermissionGroupBackgroundRefresh: + return [BackgroundRefreshStrategy new]; default: return [UnknownPermissionStrategy new]; } diff --git a/permission_handler_apple/ios/Classes/strategies/BackgroundRefreshStrategy.h b/permission_handler_apple/ios/Classes/strategies/BackgroundRefreshStrategy.h new file mode 100644 index 000000000..2dfe0032c --- /dev/null +++ b/permission_handler_apple/ios/Classes/strategies/BackgroundRefreshStrategy.h @@ -0,0 +1,17 @@ +// +// BackgroundRefreshStrategy.h +// permission_handler_apple +// +// Created by Sebastian Roth on 28/09/2023. +// + +#import +#import "PermissionStrategy.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface BackgroundRefreshStrategy : NSObject + +@end + +NS_ASSUME_NONNULL_END diff --git a/permission_handler_apple/ios/Classes/strategies/BackgroundRefreshStrategy.m b/permission_handler_apple/ios/Classes/strategies/BackgroundRefreshStrategy.m new file mode 100644 index 000000000..6208ee85c --- /dev/null +++ b/permission_handler_apple/ios/Classes/strategies/BackgroundRefreshStrategy.m @@ -0,0 +1,38 @@ +// +// BackgroundRefreshStrategy.m +// permission_handler_apple +// +// Created by Sebastian Roth on 28/09/2023. +// + +#import "BackgroundRefreshStrategy.h" + +@implementation BackgroundRefreshStrategy + +- (PermissionStatus)checkPermissionStatus:(PermissionGroup)permission { + return [BackgroundRefreshStrategy permissionStatus]; +} + +- (void)checkServiceStatus:(PermissionGroup)permission completionHandler:(ServiceStatusHandler)completionHandler { + completionHandler(ServiceStatusNotApplicable); +} + +- (void)requestPermission:(PermissionGroup)permission completionHandler:(PermissionStatusHandler)completionHandler { + completionHandler([BackgroundRefreshStrategy permissionStatus]); +} + ++ (PermissionStatus) permissionStatus { + UIBackgroundRefreshStatus status = UIApplication.sharedApplication.backgroundRefreshStatus; + switch (status) { + case UIBackgroundRefreshStatusDenied: + return PermissionStatusDenied; + case UIBackgroundRefreshStatusRestricted: + return PermissionStatusRestricted; + case UIBackgroundRefreshStatusAvailable: + return PermissionStatusGranted; + default: + return PermissionStatusDenied; + } +} + +@end diff --git a/permission_handler_apple/pubspec.yaml b/permission_handler_apple/pubspec.yaml index b916c6f89..68f1cdaff 100644 --- a/permission_handler_apple/pubspec.yaml +++ b/permission_handler_apple/pubspec.yaml @@ -2,7 +2,7 @@ name: permission_handler_apple description: Permission plugin for Flutter. This plugin provides the iOS API to request and check permissions. repository: https://github.com/baseflow/flutter-permission-handler issue_tracker: https://github.com/Baseflow/flutter-permission-handler/issues -version: 9.3.1 +version: 9.4.0 environment: @@ -19,7 +19,7 @@ flutter: dependencies: flutter: sdk: flutter - permission_handler_platform_interface: ^4.1.0 + permission_handler_platform_interface: ^4.2.0 dev_dependencies: flutter_lints: ^1.0.4 diff --git a/permission_handler_platform_interface/CHANGELOG.md b/permission_handler_platform_interface/CHANGELOG.md index dbe23da5e..e5204299f 100644 --- a/permission_handler_platform_interface/CHANGELOG.md +++ b/permission_handler_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.2.0 + +* Adds a new permission `Permission.backgroundRefresh` to check the background refresh permission status on iOS & macOS platforms. This is a no-op on all other platforms. + ## 4.1.0 * Adds the `Permission.assistant` which allows users to request permissions to access SiriKit on iOS and macOS platforms. This is a no-op on all other platforms. diff --git a/permission_handler_platform_interface/lib/src/permissions.dart b/permission_handler_platform_interface/lib/src/permissions.dart index 5f1b28be0..8f6a6a63b 100644 --- a/permission_handler_platform_interface/lib/src/permissions.dart +++ b/permission_handler_platform_interface/lib/src/permissions.dart @@ -323,6 +323,9 @@ class Permission { /// iOS: SiriKit static const assistant = Permission._(38); + /// Permission for reading the current background refresh status. (iOS only) + static const backgroundRefresh = Permission._(39); + /// Returns a list of all possible [PermissionGroup] values. static const List values = [ // ignore: deprecated_member_use_from_same_package @@ -365,6 +368,7 @@ class Permission { calendarWriteOnly, calendarFullAccess, assistant, + backgroundRefresh, ]; static const List _names = [ @@ -407,6 +411,7 @@ class Permission { 'calendarWriteOnly', 'calendarFullAccess', 'assistant', + 'backgroundRefresh' ]; @override diff --git a/permission_handler_platform_interface/pubspec.yaml b/permission_handler_platform_interface/pubspec.yaml index 392bc0475..a638b4dfb 100644 --- a/permission_handler_platform_interface/pubspec.yaml +++ b/permission_handler_platform_interface/pubspec.yaml @@ -3,7 +3,7 @@ description: A common platform interface for the permission_handler plugin. homepage: https://github.com/baseflow/flutter-permission-handler/tree/master/permission_handler_platform_interface # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 4.1.0 +version: 4.2.0 dependencies: flutter: diff --git a/permission_handler_platform_interface/test/src/permissions_test.dart b/permission_handler_platform_interface/test/src/permissions_test.dart index 43994b4f7..0f8beb470 100644 --- a/permission_handler_platform_interface/test/src/permissions_test.dart +++ b/permission_handler_platform_interface/test/src/permissions_test.dart @@ -2,14 +2,13 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:permission_handler_platform_interface/permission_handler_platform_interface.dart'; void main() { - test('Permission has the right amount of possible PermissionGroup values', - () { + test('Permission has the right amount of possible Permission values', () { const values = Permission.values; - expect(values.length, 39); + expect(values.length, 40); }); - test('check if byValue returns corresponding PermissionGroup value', () { + test('check if byValue returns corresponding Permission value', () { const values = Permission.values; for (var i = 0; i < values.length; i++) { @@ -24,6 +23,14 @@ void main() { expect(permissionName, 'Permission.calendar'); }); + test('check if toString works on all Permission values', () { + const values = Permission.values; + + for (var i = 0; i < values.length; i++) { + expect(values[i].toString(), isNotNull); + } + }); + test( // ignore: lines_longer_than_80_chars 'equality operator should return true for two instances with the same values', diff --git a/permission_handler_windows/windows/permission_constants.h b/permission_handler_windows/windows/permission_constants.h index 3c3c4b077..1bc10737c 100644 --- a/permission_handler_windows/windows/permission_constants.h +++ b/permission_handler_windows/windows/permission_constants.h @@ -49,7 +49,8 @@ class PermissionConstants { SENSORS_ALWAYS = 35, CALENDAR_WRITE_ONLY = 36, CALENDAR_FULL_ACCESS = 37, - ASSISTANT = 38 + ASSISTANT = 38, + BACKGROUND_REFRESH = 39 }; //PERMISSION_STATUS From d2aa686a46d20318ca2ea6074a6aff3715a35057 Mon Sep 17 00:00:00 2001 From: Maurits van Beusekom Date: Mon, 12 Feb 2024 16:34:14 +0100 Subject: [PATCH 2/3] Revert to platforms to main --- permission_handler/CHANGELOG.md | 6 ------ permission_handler/pubspec.yaml | 6 +++--- .../com/baseflow/permissionhandler/PermissionConstants.java | 1 - permission_handler_android/example/lib/main.dart | 3 +-- permission_handler_android/pubspec.yaml | 2 +- permission_handler_apple/CHANGELOG.md | 4 ---- .../ios/Classes/PermissionHandlerEnums.h | 3 +-- permission_handler_apple/ios/Classes/PermissionManager.h | 1 - permission_handler_apple/ios/Classes/PermissionManager.m | 2 -- permission_handler_apple/pubspec.yaml | 4 ++-- permission_handler_windows/windows/permission_constants.h | 3 +-- 11 files changed, 9 insertions(+), 26 deletions(-) diff --git a/permission_handler/CHANGELOG.md b/permission_handler/CHANGELOG.md index 070b194c9..1c252ec59 100644 --- a/permission_handler/CHANGELOG.md +++ b/permission_handler/CHANGELOG.md @@ -1,9 +1,3 @@ -## 11.3.0 - -* Adds a new permission `Permission.backgroundRefresh` to check the background refresh permission status via: - * Updates `permission_handler_apple` dependency to version 9.1.5. - * Updates `permission_handler_platform_interface` dependency to version 3.11.6. - ## 11.2.1 * Adds `PermissionGroup.photosAddOnly` to the README. diff --git a/permission_handler/pubspec.yaml b/permission_handler/pubspec.yaml index c6be8ee07..8d497272b 100644 --- a/permission_handler/pubspec.yaml +++ b/permission_handler/pubspec.yaml @@ -2,7 +2,7 @@ name: permission_handler description: Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions. repository: https://github.com/baseflow/flutter-permission-handler issue_tracker: https://github.com/Baseflow/flutter-permission-handler/issues -version: 11.3.0 +version: 11.2.1 environment: @@ -26,10 +26,10 @@ dependencies: sdk: flutter meta: ^1.7.0 permission_handler_android: ^12.0.3 - permission_handler_apple: ^9.4.0 + permission_handler_apple: ^9.3.0 permission_handler_html: ^0.1.1 permission_handler_windows: ^0.2.1 - permission_handler_platform_interface: ^4.2.0 + permission_handler_platform_interface: ^4.1.0 dev_dependencies: flutter_lints: ^1.0.4 diff --git a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java index 841595e6a..6065a8031 100644 --- a/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java +++ b/permission_handler_android/android/src/main/java/com/baseflow/permissionhandler/PermissionConstants.java @@ -61,7 +61,6 @@ final class PermissionConstants { static final int PERMISSION_GROUP_CALENDAR_WRITE_ONLY = 36; static final int PERMISSION_GROUP_CALENDAR_FULL_ACCESS = 37; static final int PERMISSION_GROUP_ASSISTANT = 38; - static final int PERMISSION_GROUP_BACKGROUND_REFRESH = 39; @Retention(RetentionPolicy.SOURCE) @IntDef({ diff --git a/permission_handler_android/example/lib/main.dart b/permission_handler_android/example/lib/main.dart index 9d1252b97..8fb6d53b1 100644 --- a/permission_handler_android/example/lib/main.dart +++ b/permission_handler_android/example/lib/main.dart @@ -42,8 +42,7 @@ class _PermissionHandlerWidgetState extends State { permission != Permission.bluetooth && permission != Permission.appTrackingTransparency && permission != Permission.criticalAlerts && - permission != Permission.assistant && - permission != Permission.backgroundRefresh; + permission != Permission.assistant; }) .map((permission) => PermissionWidget(permission)) .toList()), diff --git a/permission_handler_android/pubspec.yaml b/permission_handler_android/pubspec.yaml index 68dec9387..34616ea54 100644 --- a/permission_handler_android/pubspec.yaml +++ b/permission_handler_android/pubspec.yaml @@ -18,7 +18,7 @@ flutter: dependencies: flutter: sdk: flutter - permission_handler_platform_interface: ^4.2.0 + permission_handler_platform_interface: ^4.1.0 dev_dependencies: flutter_lints: ^1.0.4 diff --git a/permission_handler_apple/CHANGELOG.md b/permission_handler_apple/CHANGELOG.md index 1f865286f..ebeafb13c 100644 --- a/permission_handler_apple/CHANGELOG.md +++ b/permission_handler_apple/CHANGELOG.md @@ -1,7 +1,3 @@ -## 9.4.0 - -* Adds a new permission `Permission.backgroundRefresh` to check the background refresh permission status. - ## 9.3.1 * Updates plist key from `NSPhotoLibraryUsageDescription` to `NSPhotoLibraryAddUsageDescription`. diff --git a/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h b/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h index 90ef59c56..015f52d2b 100644 --- a/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h +++ b/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h @@ -162,8 +162,7 @@ typedef NS_ENUM(int, PermissionGroup) { PermissionGroupSensorsAlways, PermissionGroupCalendarWriteOnly, PermissionGroupCalendarFullAccess, - PermissionGroupAssistant, - PermissionGroupBackgroundRefresh + PermissionGroupAssistant }; typedef NS_ENUM(int, PermissionStatus) { diff --git a/permission_handler_apple/ios/Classes/PermissionManager.h b/permission_handler_apple/ios/Classes/PermissionManager.h index 4118ff83d..abaab28af 100644 --- a/permission_handler_apple/ios/Classes/PermissionManager.h +++ b/permission_handler_apple/ios/Classes/PermissionManager.h @@ -11,7 +11,6 @@ #import "AudioVideoPermissionStrategy.h" #import "AppTrackingTransparencyPermissionStrategy.h" -#import "BackgroundRefreshStrategy.h" #import "BluetoothPermissionStrategy.h" #import "ContactPermissionStrategy.h" #import "EventPermissionStrategy.h" diff --git a/permission_handler_apple/ios/Classes/PermissionManager.m b/permission_handler_apple/ios/Classes/PermissionManager.m index 7ce972f05..c4d9548d8 100644 --- a/permission_handler_apple/ios/Classes/PermissionManager.m +++ b/permission_handler_apple/ios/Classes/PermissionManager.m @@ -149,8 +149,6 @@ + (id)createPermissionStrategy:(PermissionGroup)permission { return [CriticalAlertsPermissionStrategy new]; case PermissionGroupAssistant: return [AssistantPermissionStrategy new]; - case PermissionGroupBackgroundRefresh: - return [BackgroundRefreshStrategy new]; default: return [UnknownPermissionStrategy new]; } diff --git a/permission_handler_apple/pubspec.yaml b/permission_handler_apple/pubspec.yaml index 68f1cdaff..b916c6f89 100644 --- a/permission_handler_apple/pubspec.yaml +++ b/permission_handler_apple/pubspec.yaml @@ -2,7 +2,7 @@ name: permission_handler_apple description: Permission plugin for Flutter. This plugin provides the iOS API to request and check permissions. repository: https://github.com/baseflow/flutter-permission-handler issue_tracker: https://github.com/Baseflow/flutter-permission-handler/issues -version: 9.4.0 +version: 9.3.1 environment: @@ -19,7 +19,7 @@ flutter: dependencies: flutter: sdk: flutter - permission_handler_platform_interface: ^4.2.0 + permission_handler_platform_interface: ^4.1.0 dev_dependencies: flutter_lints: ^1.0.4 diff --git a/permission_handler_windows/windows/permission_constants.h b/permission_handler_windows/windows/permission_constants.h index 1bc10737c..3c3c4b077 100644 --- a/permission_handler_windows/windows/permission_constants.h +++ b/permission_handler_windows/windows/permission_constants.h @@ -49,8 +49,7 @@ class PermissionConstants { SENSORS_ALWAYS = 35, CALENDAR_WRITE_ONLY = 36, CALENDAR_FULL_ACCESS = 37, - ASSISTANT = 38, - BACKGROUND_REFRESH = 39 + ASSISTANT = 38 }; //PERMISSION_STATUS From 703bcde5e96c1d490c7c8f0261ca77831625d048 Mon Sep 17 00:00:00 2001 From: Maurits van Beusekom Date: Mon, 12 Feb 2024 16:35:48 +0100 Subject: [PATCH 3/3] Revert changes to Apple package --- .../strategies/BackgroundRefreshStrategy.h | 17 --------- .../strategies/BackgroundRefreshStrategy.m | 38 ------------------- 2 files changed, 55 deletions(-) delete mode 100644 permission_handler_apple/ios/Classes/strategies/BackgroundRefreshStrategy.h delete mode 100644 permission_handler_apple/ios/Classes/strategies/BackgroundRefreshStrategy.m diff --git a/permission_handler_apple/ios/Classes/strategies/BackgroundRefreshStrategy.h b/permission_handler_apple/ios/Classes/strategies/BackgroundRefreshStrategy.h deleted file mode 100644 index 2dfe0032c..000000000 --- a/permission_handler_apple/ios/Classes/strategies/BackgroundRefreshStrategy.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// BackgroundRefreshStrategy.h -// permission_handler_apple -// -// Created by Sebastian Roth on 28/09/2023. -// - -#import -#import "PermissionStrategy.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface BackgroundRefreshStrategy : NSObject - -@end - -NS_ASSUME_NONNULL_END diff --git a/permission_handler_apple/ios/Classes/strategies/BackgroundRefreshStrategy.m b/permission_handler_apple/ios/Classes/strategies/BackgroundRefreshStrategy.m deleted file mode 100644 index 6208ee85c..000000000 --- a/permission_handler_apple/ios/Classes/strategies/BackgroundRefreshStrategy.m +++ /dev/null @@ -1,38 +0,0 @@ -// -// BackgroundRefreshStrategy.m -// permission_handler_apple -// -// Created by Sebastian Roth on 28/09/2023. -// - -#import "BackgroundRefreshStrategy.h" - -@implementation BackgroundRefreshStrategy - -- (PermissionStatus)checkPermissionStatus:(PermissionGroup)permission { - return [BackgroundRefreshStrategy permissionStatus]; -} - -- (void)checkServiceStatus:(PermissionGroup)permission completionHandler:(ServiceStatusHandler)completionHandler { - completionHandler(ServiceStatusNotApplicable); -} - -- (void)requestPermission:(PermissionGroup)permission completionHandler:(PermissionStatusHandler)completionHandler { - completionHandler([BackgroundRefreshStrategy permissionStatus]); -} - -+ (PermissionStatus) permissionStatus { - UIBackgroundRefreshStatus status = UIApplication.sharedApplication.backgroundRefreshStatus; - switch (status) { - case UIBackgroundRefreshStatusDenied: - return PermissionStatusDenied; - case UIBackgroundRefreshStatusRestricted: - return PermissionStatusRestricted; - case UIBackgroundRefreshStatusAvailable: - return PermissionStatusGranted; - default: - return PermissionStatusDenied; - } -} - -@end