Commit cde241f7 by Maurits van Beusekom Committed by GitHub

Background refresh status platform specific implementations (#1282)

* Fix/1174 background refresh status (#1176)

* Update project files

* Add a new background refresh permission check for iOS

* versions

* cleanups

* version bumps

* missing constants

* Revert to platforms to main

---------

Co-authored-by: Sebastian Roth <sebastian.roth@gmail.com>
parent c013888b
......@@ -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({
......
......@@ -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()),
......
......@@ -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
......
## 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`.
......
......@@ -162,7 +162,8 @@ typedef NS_ENUM(int, PermissionGroup) {
PermissionGroupSensorsAlways,
PermissionGroupCalendarWriteOnly,
PermissionGroupCalendarFullAccess,
PermissionGroupAssistant
PermissionGroupAssistant,
PermissionGroupBackgroundRefresh
};
typedef NS_ENUM(int, PermissionStatus) {
......
......@@ -11,6 +11,7 @@
#import "AudioVideoPermissionStrategy.h"
#import "AppTrackingTransparencyPermissionStrategy.h"
#import "BackgroundRefreshStrategy.h"
#import "BluetoothPermissionStrategy.h"
#import "ContactPermissionStrategy.h"
#import "EventPermissionStrategy.h"
......
......@@ -149,6 +149,8 @@
return [CriticalAlertsPermissionStrategy new];
case PermissionGroupAssistant:
return [AssistantPermissionStrategy new];
case PermissionGroupBackgroundRefresh:
return [BackgroundRefreshStrategy new];
default:
return [UnknownPermissionStrategy new];
}
......
//
// 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
//
// 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
......@@ -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
......
......@@ -49,7 +49,8 @@ public:
SENSORS_ALWAYS = 35,
CALENDAR_WRITE_ONLY = 36,
CALENDAR_FULL_ACCESS = 37,
ASSISTANT = 38
ASSISTANT = 38,
BACKGROUND_REFRESH = 39
};
//PERMISSION_STATUS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment