Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background refresh status platform specific implementations #1282

Merged
merged 3 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
3 changes: 2 additions & 1 deletion permission_handler_android/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class _PermissionHandlerWidgetState extends State<PermissionHandlerWidget> {
permission != Permission.bluetooth &&
permission != Permission.appTrackingTransparency &&
permission != Permission.criticalAlerts &&
permission != Permission.assistant;
permission != Permission.assistant &&
permission != Permission.backgroundRefresh;
})
.map((permission) => PermissionWidget(permission))
.toList()),
Expand Down
2 changes: 1 addition & 1 deletion permission_handler_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions permission_handler_apple/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ typedef NS_ENUM(int, PermissionGroup) {
PermissionGroupSensorsAlways,
PermissionGroupCalendarWriteOnly,
PermissionGroupCalendarFullAccess,
PermissionGroupAssistant
PermissionGroupAssistant,
PermissionGroupBackgroundRefresh
};

typedef NS_ENUM(int, PermissionStatus) {
Expand Down
1 change: 1 addition & 0 deletions permission_handler_apple/ios/Classes/PermissionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#import "AudioVideoPermissionStrategy.h"
#import "AppTrackingTransparencyPermissionStrategy.h"
#import "BackgroundRefreshStrategy.h"
#import "BluetoothPermissionStrategy.h"
#import "ContactPermissionStrategy.h"
#import "EventPermissionStrategy.h"
Expand Down
2 changes: 2 additions & 0 deletions permission_handler_apple/ios/Classes/PermissionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// BackgroundRefreshStrategy.h
// permission_handler_apple
//
// Created by Sebastian Roth on 28/09/2023.
//

#import <Foundation/Foundation.h>
#import "PermissionStrategy.h"

NS_ASSUME_NONNULL_BEGIN

@interface BackgroundRefreshStrategy : NSObject<PermissionStrategy>

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions permission_handler_apple/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion permission_handler_windows/windows/permission_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading