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_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