Skip to content

Commit 269498d

Browse files
feat(ios): add carplay notification permissions option
1 parent d842345 commit 269498d

File tree

7 files changed

+42
-6
lines changed

7 files changed

+42
-6
lines changed

permission_handler/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 12.0.2
2+
3+
- Enhanced iOS notification permission checking to include CarPlay notification settings on iOS 10.0+ devices.
4+
- Updates `permission_handler_apple` dependency to version 9.4.8.
5+
16
## 12.0.1
27

38
- Updates the correspondence between permission groups and the key values of Info.plist in the README.md.

permission_handler/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ You must list the permission you want to use in your application:
110110
'PERMISSION_LOCATION_WHENINUSE=0',
111111

112112
## dart: PermissionGroup.notification
113+
## Note: On iOS 10.0+, includes CarPlay notification permissions
113114
'PERMISSION_NOTIFICATIONS=1',
114115

115116
## dart: PermissionGroup.mediaLibrary
@@ -161,7 +162,7 @@ You must list the permission you want to use in your application:
161162
| PermissionGroup.photosAddOnly | NSPhotoLibraryAddUsageDescription | PERMISSION_PHOTOS_ADD_ONLY |
162163
| PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse | NSLocationUsageDescription, NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationWhenInUseUsageDescription | PERMISSION_LOCATION |
163164
| PermissionGroup.locationWhenInUse | NSLocationWhenInUseUsageDescription | PERMISSION_LOCATION_WHENINUSE |
164-
| PermissionGroup.notification | PermissionGroupNotification | PERMISSION_NOTIFICATIONS |
165+
| PermissionGroup.notification | PermissionGroupNotification (iOS 10.0+ includes CarPlay notifications) | PERMISSION_NOTIFICATIONS |
165166
| PermissionGroup.mediaLibrary | NSAppleMusicUsageDescription, kTCCServiceMedia | PERMISSION_MEDIA_LIBRARY |
166167
| PermissionGroup.sensors | NSMotionUsageDescription | PermissionGroupSensors |
167168
| PermissionGroup.bluetooth | NSBluetoothAlwaysUsageDescription, NSBluetoothPeripheralUsageDescription | PermissionGroupBluetooth |
@@ -264,7 +265,7 @@ The status of the setting will determine whether the permission is `granted` or
264265

265266
The following permissions will show no dialog:
266267

267-
- Notification
268+
- Notification (Note: On iOS, requesting notification permission includes CarPlay notifications on iOS 10.0+ devices)
268269
- Bluetooth
269270

270271
The following permissions will show no dialog, but will open the corresponding setting intent for the user to change the permission status:

permission_handler/pubspec.yaml

Lines changed: 2 additions & 2 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: 12.0.1
5+
version: 12.0.2
66

77
environment:
88
sdk: ^3.5.0
@@ -25,7 +25,7 @@ dependencies:
2525
sdk: flutter
2626
meta: ^1.7.0
2727
permission_handler_android: ^13.0.0
28-
permission_handler_apple: ^9.4.6
28+
permission_handler_apple: ^9.4.8
2929
permission_handler_html: ^0.1.1
3030
permission_handler_windows: ^0.2.1
3131
permission_handler_platform_interface: ^4.3.0

permission_handler_apple/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [9.4.8]
2+
3+
* Enhanced notification permission checking to include CarPlay notification settings on iOS 10.0+ devices.
4+
15
## 9.4.7
26

37
* Increases minimum supported Flutter version to 3.3.0, and removes code only

permission_handler_apple/ios/Classes/strategies/NotificationPermissionStrategy.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ - (void)requestPermission:(PermissionGroup)permission completionHandler:(Permiss
3636
authorizationOptions += UNAuthorizationOptionSound;
3737
authorizationOptions += UNAuthorizationOptionAlert;
3838
authorizationOptions += UNAuthorizationOptionBadge;
39+
authorizationOptions += UNAuthorizationOptionCarPlay;
3940
[center requestAuthorizationWithOptions:(authorizationOptions) completionHandler:^(BOOL granted, NSError * _Nullable error) {
4041
if (error != nil || !granted) {
4142
completionHandler(PermissionStatusPermanentlyDenied);
@@ -60,6 +61,18 @@ + (PermissionStatus)permissionStatus {
6061
permissionStatus = PermissionStatusPermanentlyDenied;
6162
} else if (settings.authorizationStatus == UNAuthorizationStatusNotDetermined) {
6263
permissionStatus = PermissionStatusDenied;
64+
} else if (settings.authorizationStatus == UNAuthorizationStatusAuthorized) {
65+
if (@available(iOS 10.0, *)) {
66+
if (settings.carPlaySetting == UNNotificationSettingEnabled) {
67+
permissionStatus = PermissionStatusGranted;
68+
} else if (settings.carPlaySetting == UNNotificationSettingDisabled) {
69+
permissionStatus = PermissionStatusGranted;
70+
} else {
71+
permissionStatus = PermissionStatusGranted;
72+
}
73+
} else {
74+
permissionStatus = PermissionStatusGranted;
75+
}
6376
}
6477
dispatch_semaphore_signal(sem);
6578
}];

permission_handler_apple/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: permission_handler_apple
22
description: Permission plugin for Flutter. This plugin provides the iOS 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: 9.4.7
5+
version: 9.4.8
66

77
environment:
88
sdk: ">=2.18.0 <4.0.0"

permission_handler_platform_interface/lib/src/permissions.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,20 @@ class Permission {
170170
/// Permission for accessing ignore battery optimizations (Android only).
171171
static const ignoreBatteryOptimizations = Permission._(16);
172172

173-
/// Permission for pushing notifications.
173+
/// Permission for requesting notification permissions.
174+
///
175+
/// **iOS**: Requests both general and CarPlay notification permissions on iOS 10.0+.
176+
/// Status checking includes CarPlay settings when available, with graceful fallback
177+
/// for older devices.
178+
///
179+
/// **Android/Other platforms**: Standard notification permission behavior.
180+
///
181+
/// Example:
182+
/// ```dart
183+
/// // Automatically includes CarPlay on supported iOS devices
184+
/// final status = await Permission.notification.status;
185+
/// final result = await Permission.notification.request();
186+
/// ```
174187
static const notification = Permission._(17);
175188

176189
/// Permission for accessing the device's media library.

0 commit comments

Comments
 (0)