Skip to content

Commit e3c92e3

Browse files
MilosKarakasmilosKarakasTimHoogstrateJeroenWeenermvanbeusekom
authored
Support Calendar Access Levels (iOS17+) (#1151)
* - Split iOS calendar permission into write only and full access * - Fixes + adjust readme and bump versions * - Adjust Changelog.md * - Support iOS 17+ calendar permissions * - Update README.md to reflect iOS 17+ calendar permissions * - Fix PermissionManager.m issue * - Fix dependencies * #1108 Adjusted for calendarReadOnly and calendarFullAccess * #1108 Remove breaking change annotation from changelog * Switch calendarReadOnly to calendarWriteOnly * Update permission_handler/CHANGELOG.md Co-authored-by: TimHoogstrate <tim566@hotmail.com> * - Adjusted iOS EventPermissionStrategy.m after review * Added NSCalendarsFullAccessUsageDescription to apple example .plist and podfile * Fix deprecated calendar permission logic * Update EventPermissionStrategy.m * Make small adjustments * Make small touch-ups * Updates `Runner.xcodeproj` files * Update permission_handler/README.md Co-authored-by: TimHoogstrate <tim566@hotmail.com> * Update permission_handler/README.md Co-authored-by: TimHoogstrate <tim566@hotmail.com> * Replace `calendar` with `contacts` in tests * Update permission_handler_apple.yaml * Update permission_handler.yaml * Update permission_handler.yaml * Update permission_handler_apple.yaml --------- Co-authored-by: milosKarakas <milos.karakas@codebluestudio.com> Co-authored-by: TimHoogstrate <tim566@hotmail.com> Co-authored-by: Jeroen Weener <JeroenWeener@users.noreply.github.com> Co-authored-by: Maurits van Beusekom <maurits@baseflow.com>
1 parent 5b4a5c4 commit e3c92e3

File tree

10 files changed

+81
-40
lines changed

10 files changed

+81
-40
lines changed

.github/workflows/permission_handler.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ jobs:
2222
name: App facing package
2323

2424
# The type of runner that the job will run on
25-
runs-on: macos-latest
25+
#
26+
# TODO(mvanbeusekom): Manually set to macOS 13 to support Xcode 15 and iOS 17 SDKs.
27+
# Currently `macos-latest` is based on macOS 12 and doesn't support iOS 17 SDK. This
28+
# should be moved back to `macos-latest` when GitHub Actions images are updated.
29+
runs-on: macos-13
2630

2731
env:
2832
source-directory: ./permission_handler
@@ -33,6 +37,13 @@ jobs:
3337
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
3438
- uses: actions/checkout@v3
3539

40+
# Override current Xcode version with version 15.0.1.
41+
#
42+
# TODO(mvanbeusekom): Remove when the macos-latest image supports version 15.0.1
43+
# out of the box (see https://github.com/actions/runner-images/blob/main/README.md).
44+
- name: Select Xcode version
45+
run: sudo xcode-select -s '/Applications/Xcode_15.0.1.app/Contents/Developer'
46+
3647
# Make sure JAVA version 17 is installed on build agent.
3748
- uses: actions/setup-java@v3
3849
with:

.github/workflows/permission_handler_apple.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ jobs:
2222
name: Apple platform package
2323

2424
# The type of runner that the job will run on
25-
runs-on: macos-latest
25+
#
26+
# TODO(mvanbeusekom): Manually set to macOS 13 to support Xcode 15 and iOS 17 SDKs.
27+
# Currently `macos-latest` is based on macOS 12 and doesn't support iOS 17 SDK. This
28+
# should be moved back to `macos-latest` when GitHub Actions images are updated.
29+
runs-on: macos-13
2630

2731
env:
2832
source-directory: ./permission_handler_apple
@@ -32,6 +36,13 @@ jobs:
3236
steps:
3337
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
3438
- uses: actions/checkout@v3
39+
40+
# Override current Xcode version with version 15.0.1.
41+
#
42+
# TODO(mvanbeusekom): Remove when the macos-latest image supports version 15.0.1
43+
# out of the box (see https://github.com/actions/runner-images/blob/main/README.md).
44+
- name: Select Xcode version
45+
run: sudo xcode-select -s '/Applications/Xcode_15.0.1.app/Contents/Developer'
3546

3647
# Make sure the stable version of Flutter is available
3748
- uses: subosito/flutter-action@v2

permission_handler/CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 11.1.0
2+
* Adds support for iOS 17+ [Calendar access levels](https://developer.apple.com/documentation/technotes/tn3152-migrating-to-the-latest-calendar-access-levels).
3+
* Deprecates `Permission.calendar`. Use `Permission.calendarWriteOnly` to request a write-only access to the calendar. For full access to calendar use `Permission.calendarFullAccess`.
4+
* For `Permission.calendarFullAccess` on iOS 17+ use `PERMISSION_EVENTS_FULL_ACCESS` in Podfile instead of `PERMISSION_EVENTS`.
5+
* Adds web support by endorsing `permission_handler_html` as the web implementation of the permission handler. Only some permissions are supported at this time.
6+
* Updates `permission_handler_android` dependency to version 12.0.1.
7+
* Updates `permission_handler_apple` dependency to version 9.2.0.
8+
* Updates `permission_handler_windows` dependency to version 0.2.0.
9+
* Updates `permission_handler_platform_interface` dependency to version 4.0.2.
10+
111
## 11.0.1
212

313
* Adds extension methods to the `PermissionStatus` enum allowing developers to register callback methods, which will improve code readability.
@@ -74,7 +84,7 @@
7484

7585
## 9.0.2
7686

77-
* Fixes regression when requesting 'locationAlways' permission on Andriod 9 (Pie) and earlier.
87+
* Fixes regression when requesting 'locationAlways' permission on Android 9 (Pie) and earlier.
7888

7989
## 9.0.1
8090

permission_handler/README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,12 @@ You must list the permission you want to use in your application:
8383
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
8484
'$(inherited)',
8585

86-
## dart: PermissionGroup.calendar
86+
## dart: [PermissionGroup.calendarWriteOnly, PermissionGroup.calendar (iOS 16 and below)]
8787
# 'PERMISSION_EVENTS=1',
88-
88+
89+
## dart: [PermissionGroup.calendarFullAccess, PermissionGroup.calendar (iOS 17 and above)]
90+
# 'PERMISSION_EVENTS_FULL_ACCESS=1',
91+
8992
## dart: PermissionGroup.reminders
9093
# 'PERMISSION_REMINDERS=1',
9194

@@ -143,22 +146,20 @@ You must list the permission you want to use in your application:
143146
e.g. when you don't need camera permission, just delete 'NSCameraUsageDescription'
144147
The following lists the relationship between `Permission` and `The key of Info.plist`:
145148

146-
| Permission | Info.plist | Macro |
147-
| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
148-
| PermissionGroup.calendar | NSCalendarsUsageDescription | PERMISSION_EVENTS |
149-
| PermissionGroup.reminders | NSRemindersUsageDescription | PERMISSION_REMINDERS |
150-
| PermissionGroup.contacts | NSContactsUsageDescription | PERMISSION_CONTACTS |
151-
| PermissionGroup.camera | NSCameraUsageDescription | PERMISSION_CAMERA |
152-
| PermissionGroup.microphone | NSMicrophoneUsageDescription | PERMISSION_MICROPHONE |
153-
| PermissionGroup.speech | NSSpeechRecognitionUsageDescription | PERMISSION_SPEECH_RECOGNIZER |
154-
| PermissionGroup.photos | NSPhotoLibraryUsageDescription | PERMISSION_PHOTOS |
155-
| PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse | NSLocationUsageDescription, NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationWhenInUseUsageDescription | PERMISSION_LOCATION |
156-
| PermissionGroup.notification | PermissionGroupNotification | PERMISSION_NOTIFICATIONS |
157-
| PermissionGroup.mediaLibrary | NSAppleMusicUsageDescription, kTCCServiceMediaLibrary | PERMISSION_MEDIA_LIBRARY |
158-
| PermissionGroup.sensors | NSMotionUsageDescription | PERMISSION_SENSORS |
159-
| PermissionGroup.bluetooth | NSBluetoothAlwaysUsageDescription, NSBluetoothPeripheralUsageDescription | PERMISSION_BLUETOOTH |
160-
| PermissionGroup.appTrackingTransparency | NSUserTrackingUsageDescription | PERMISSION_APP_TRACKING_TRANSPARENCY |
161-
| PermissionGroup.criticalAlerts | PermissionGroupCriticalAlerts | PERMISSION_CRITICAL_ALERTS |
149+
| Permission | Info.plist | Macro |
150+
|-------------------------------------------------------------------------------------------| ------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
151+
| PermissionGroup.calendar (< iOS 17) | NSCalendarsUsageDescription | PERMISSION_EVENTS |
152+
| PermissionGroup.calendarWriteOnly (iOS 17+) | NSCalendarsWriteOnlyAccessUsageDescription | PERMISSION_EVENTS |
153+
| PermissionGroup.calendarFullAccess (iOS 17+) | NSCalendarsFullAccessUsageDescription | PERMISSION_EVENTS_FULL_ACCESS |
154+
| PermissionGroup.reminders | NSRemindersUsageDescription | PERMISSION_REMINDERS |
155+
| PermissionGroup.contacts | NSContactsUsageDescription | PERMISSION_CONTACTS |
156+
| PermissionGroup.camera | NSCameraUsageDescription | PERMISSION_CAMERA |
157+
| PermissionGroup.microphone | NSMicrophoneUsageDescription | PERMISSION_MICROPHONE |
158+
| PermissionGroup.speech | NSSpeechRecognitionUsageDescription | PERMISSION_SPEECH_RECOGNIZER |
159+
| PermissionGroup.photos | NSPhotoLibraryUsageDescription | PERMISSION_PHOTOS |
160+
| PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse | NSLocationUsageDescription, NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationWhenInUseUsageDescription | PERMISSION_LOCATION |
161+
| PermissionGroup.notification | PermissionGroupNotification | PERMISSION_NOTIFICATIONS |
162+
| PermissionGroup.mediaLibrary | NSAppleMusicUsageDescription, kTCCServiceMedia
162163

163164
4. Clean & Rebuild
164165

permission_handler/example/ios/Podfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ post_install do |installer|
4545
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
4646
'$(inherited)',
4747

48-
## dart: PermissionGroup.calendar
48+
## dart: [PermissionGroup.calendarWriteOnly, PermissionGroup.calendar (until iOS 16)]
4949
'PERMISSION_EVENTS=1',
50+
51+
## dart: [PermissionGroup.calendarFullAccess, PermissionGroup.calendar (from iOS 17)]
52+
'PERMISSION_EVENTS_FULL_ACCESS=1',
5053

5154
## dart: PermissionGroup.reminders
5255
'PERMISSION_REMINDERS=1',

permission_handler/example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
97C146E61CF9000F007C117D /* Project object */ = {
156156
isa = PBXProject;
157157
attributes = {
158-
LastUpgradeCheck = 1300;
158+
LastUpgradeCheck = 1430;
159159
ORGANIZATIONNAME = "";
160160
TargetAttributes = {
161161
97C146ED1CF9000F007C117D = {

permission_handler/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1300"
3+
LastUpgradeVersion = "1430"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

permission_handler/example/ios/Runner/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
<!-- Permission options for the `calendar` group -->
6262
<key>NSCalendarsUsageDescription</key>
6363
<string>Calendars</string>
64+
<key>NSCalendarsFullAccessUsageDescription</key>
65+
<string>Calendar full access</string>
6466

6567
<!-- Permission options for the `camera` group -->
6668
<key>NSCameraUsageDescription</key>

permission_handler/pubspec.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: permission_handler
22
description: Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
33
repository: https://github.com/baseflow/flutter-permission-handler
44
issue_tracker: https://github.com/Baseflow/flutter-permission-handler/issues
5-
version: 11.0.1
5+
version: 11.1.0
66

77
environment:
88
sdk: ">=2.15.0 <4.0.0"
@@ -15,17 +15,20 @@ flutter:
1515
default_package: permission_handler_android
1616
ios:
1717
default_package: permission_handler_apple
18+
web:
19+
default_package: permission_handler_html
1820
windows:
1921
default_package: permission_handler_windows
2022

2123
dependencies:
2224
flutter:
2325
sdk: flutter
2426
meta: ^1.7.0
25-
permission_handler_android: ^11.0.0
26-
permission_handler_apple: ^9.1.4
27-
permission_handler_windows: ^0.1.3
28-
permission_handler_platform_interface: ^3.11.5
27+
permission_handler_android: ^12.0.1
28+
permission_handler_apple: ^9.2.0
29+
permission_handler_html: ^0.1.0+1
30+
permission_handler_windows: ^0.2.0
31+
permission_handler_platform_interface: ^4.0.2
2932

3033
dev_dependencies:
3134
flutter_lints: ^1.0.4

permission_handler/test/permission_handler_test.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void main() {
1717
});
1818

1919
test('PermissionActions on Permission: get status', () async {
20-
final permissionStatus = await Permission.calendar.status;
20+
final permissionStatus = await Permission.contacts.status;
2121

2222
expect(permissionStatus, PermissionStatus.granted);
2323
});
@@ -29,50 +29,50 @@ void main() {
2929
final mockPermissionHandlerPlatform = PermissionHandlerPlatform.instance;
3030

3131
when(mockPermissionHandlerPlatform
32-
.shouldShowRequestPermissionRationale(Permission.calendar))
32+
.shouldShowRequestPermissionRationale(Permission.contacts))
3333
.thenAnswer((_) => Future.value(true));
3434

35-
await Permission.calendar.shouldShowRequestRationale;
35+
await Permission.contacts.shouldShowRequestRationale;
3636

3737
verify(mockPermissionHandlerPlatform
38-
.shouldShowRequestPermissionRationale(Permission.calendar))
38+
.shouldShowRequestPermissionRationale(Permission.contacts))
3939
.called(1);
4040
});
4141

4242
test('PermissionActions on Permission: request()', () async {
43-
final permissionRequest = Permission.calendar.request();
43+
final permissionRequest = Permission.contacts.request();
4444

4545
expect(permissionRequest, isA<Future<PermissionStatus>>());
4646
});
4747

4848
test('PermissionCheckShortcuts on Permission: get isGranted', () async {
49-
final isGranted = await Permission.calendar.isGranted;
49+
final isGranted = await Permission.contacts.isGranted;
5050
expect(isGranted, true);
5151
});
5252

5353
test('PermissionCheckShortcuts on Permission: get isDenied', () async {
54-
final isDenied = await Permission.calendar.isDenied;
54+
final isDenied = await Permission.contacts.isDenied;
5555
expect(isDenied, false);
5656
});
5757

5858
test('PermissionCheckShortcuts on Permission: get isRestricted', () async {
59-
final isRestricted = await Permission.calendar.isRestricted;
59+
final isRestricted = await Permission.contacts.isRestricted;
6060
expect(isRestricted, false);
6161
});
6262

6363
test('PermissionCheckShortcuts on Permission: get isLimited', () async {
64-
final isLimited = await Permission.calendar.isLimited;
64+
final isLimited = await Permission.contacts.isLimited;
6565
expect(isLimited, false);
6666
});
6767

6868
test('PermissionCheckShortcuts on Permission: get isPermanentlyDenied',
6969
() async {
70-
final isPermanentlyDenied = await Permission.calendar.isPermanentlyDenied;
70+
final isPermanentlyDenied = await Permission.contacts.isPermanentlyDenied;
7171
expect(isPermanentlyDenied, false);
7272
});
7373

7474
test('PermissionCheckShortcuts on Permission: get isProvisional', () async {
75-
final isProvisional = await Permission.calendar.isProvisional;
75+
final isProvisional = await Permission.contacts.isProvisional;
7676
expect(isProvisional, false);
7777
});
7878

0 commit comments

Comments
 (0)