From c013888b8013adf8fbe8bdc1d52b2aab4daa211f Mon Sep 17 00:00:00 2001 From: Maurits van Beusekom Date: Mon, 12 Feb 2024 16:39:22 +0100 Subject: [PATCH] Background refresh status platform interface (#1281) * 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 * Revert changes to Apple package --------- Co-authored-by: Sebastian Roth --- .../CHANGELOG.md | 4 ++++ .../lib/src/permissions.dart | 5 +++++ .../pubspec.yaml | 2 +- .../test/src/permissions_test.dart | 15 +++++++++++---- 4 files changed, 21 insertions(+), 5 deletions(-) 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',