Skip to content

Commit 78a549c

Browse files
Adds support to request Siri permission on iOS. (#1265)
* Adding SiriKit permissions (#1140) * Adding SiriKit permissions * Fix tests --------- Co-authored-by: Maurits van Beusekom <maurits@vnbskm.nl> * Reserves the assistant permission on no-op platforms * Adds support to example application * Remove pubspec overrides * Fix formatting * Add support for Permission.assistant to the app facing package. * Fix formatting --------- Co-authored-by: Baptiste DUPUCH <baptiste.dupuch@gmail.com>
1 parent e0b76c2 commit 78a549c

File tree

8 files changed

+56
-12
lines changed

8 files changed

+56
-12
lines changed

permission_handler/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
## 11.2.0
2+
3+
* 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.
4+
15
## 11.1.0
6+
27
* Adds support for iOS 17+ [Calendar access levels](https://developer.apple.com/documentation/technotes/tn3152-migrating-to-the-latest-calendar-access-levels).
38
* Deprecates `Permission.calendar`. Use `Permission.calendarWriteOnly` to request a write-only access to the calendar. For full access to calendar use `Permission.calendarFullAccess`.
49
* For `Permission.calendarFullAccess` on iOS 17+ use `PERMISSION_EVENTS_FULL_ACCESS` in Podfile instead of `PERMISSION_EVENTS`.

permission_handler/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,25 @@ If your application needs access to Android's file system, it is possible to req
283283

284284
Starting with Android 10, apps are required to first obtain permission to read the device's location in the foreground, before requesting to read the location in the background as well. When requesting the 'location always' permission directly, or when requesting both permissions at the same time, the system will ignore the request. So, instead of calling only `Permission.location.request()`, make sure to first call either `Permission.location.request()` or `Permission.locationWhenInUse.request()`, and obtain permission to read the GPS. Once you obtain this permission, you can call `Permission.locationAlways.request()`. This will present the user with the option to update the settings so the location can always be read in the background. For more information, visit the [Android documentation on requesting location permissions](https://developer.android.com/training/location/permissions#request-only-foreground).
285285

286+
### Checking or requesting a permission terminates the application on iOS. What can I do?
287+
288+
First of all make sure all that the `ios/Runner/Info.plist` file contains entries for all the permissions the application requires. If an entry is missing iOS will terminate the application as soon as the particular permission is being checked or requested.
289+
290+
If the application requires access to SiriKit (by requesting the `Permission.assistant` permission), also make sure to add the `com.apple.developer.siri` entitlement to the application configuration. To do so create a file (if it doesn't exists already) called `Runner.entitlements` in the `ios/Runner` folder that is part of the project. Open the file and add the following contents:
291+
292+
```xml
293+
<?xml version="1.0" encoding="UTF-8"?>
294+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
295+
<plist version="1.0">
296+
<dict>
297+
<key>com.apple.developer.siri</key>
298+
<true/>
299+
</dict>
300+
</plist>
301+
```
302+
303+
The important part here is the `key` with value `com.apple.developer.siri` and the element `<true/>`. It is possible that this file also contains other entitlements depending on the needs of the application.
304+
286305
## Issues
287306

288307
Please file any issues, bugs, or feature requests as an issue on our [GitHub](https://github.com/Baseflow/flutter-permission-handler/issues) page. Commercial support is available if you need help with integration with your app or services. You can contact us at [hello@baseflow.com](mailto:hello@baseflow.com).

permission_handler/example/ios/Podfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ post_install do |installer|
7171

7272
## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse]
7373
'PERMISSION_LOCATION=1',
74-
74+
7575
## dart: PermissionGroup.notification
7676
'PERMISSION_NOTIFICATIONS=1',
7777

@@ -89,6 +89,9 @@ post_install do |installer|
8989

9090
## dart: PermissionGroup.criticalAlerts
9191
'PERMISSION_CRITICAL_ALERTS=1',
92+
93+
## dart: PermissionGroup.assistant
94+
'PERMISSION_ASSISTANT=1',
9295
]
9396

9497
end

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
C446183715B92022DDB68882 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
4848
CEA40B36DE135D81D16B7399 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
4949
DA7CB50DE8057A7A8D126AC9 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
50+
F6BD02752B56D87600C59EAA /* RunnerDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = RunnerDebug.entitlements; sourceTree = "<group>"; };
5051
/* End PBXFileReference section */
5152

5253
/* Begin PBXFrameworksBuildPhase section */
@@ -112,6 +113,7 @@
112113
97C146F01CF9000F007C117D /* Runner */ = {
113114
isa = PBXGroup;
114115
children = (
116+
F6BD02752B56D87600C59EAA /* RunnerDebug.entitlements */,
115117
97C146FA1CF9000F007C117D /* Main.storyboard */,
116118
97C146FD1CF9000F007C117D /* Assets.xcassets */,
117119
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
@@ -494,6 +496,7 @@
494496
buildSettings = {
495497
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
496498
CLANG_ENABLE_MODULES = YES;
499+
CODE_SIGN_ENTITLEMENTS = Runner/RunnerDebug.entitlements;
497500
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
498501
DEVELOPMENT_TEAM = 7624MWN53C;
499502
ENABLE_BITCODE = NO;

permission_handler/example/ios/Runner/Info.plist

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,14 @@
101101
<!-- Permission options for the `appTrackingTransparency` -->
102102
<key>NSUserTrackingUsageDescription</key>
103103
<string>appTrackingTransparency</string>
104-
<key>CADisableMinimumFrameDurationOnPhone</key>
105-
<true/>
106-
<key>UIApplicationSupportsIndirectInputEvents</key>
107-
<true/>
104+
105+
<!-- Permission options for the `assistant` group -->
106+
<key>NSSiriUsageDescription</key>
107+
<string>The example app would like access to Siri Kit to demonstrate requesting authorization.</string>
108+
109+
<key>CADisableMinimumFrameDurationOnPhone</key>
110+
<true/>
111+
<key>UIApplicationSupportsIndirectInputEvents</key>
112+
<true/>
108113
</dict>
109114
</plist>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.developer.siri</key>
6+
<true/>
7+
</dict>
8+
</plist>

permission_handler/example/lib/main.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ class _PermissionHandlerWidgetState extends State<PermissionHandlerWidget> {
6363
permission != Permission.reminders &&
6464
permission != Permission.bluetooth &&
6565
permission != Permission.appTrackingTransparency &&
66-
permission != Permission.criticalAlerts;
66+
permission != Permission.criticalAlerts &&
67+
permission != Permission.assistant;
6768
}
6869
})
6970
.map((permission) => PermissionWidget(permission))

permission_handler/pubspec.yaml

Lines changed: 6 additions & 6 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.1.0
5+
version: 11.2.0
66

77
environment:
88
sdk: ">=2.15.0 <4.0.0"
@@ -24,11 +24,11 @@ dependencies:
2424
flutter:
2525
sdk: flutter
2626
meta: ^1.7.0
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
27+
permission_handler_android: ^12.0.3
28+
permission_handler_apple: ^9.3.0
29+
permission_handler_html: ^0.1.1
30+
permission_handler_windows: ^0.2.1
31+
permission_handler_platform_interface: ^4.1.0
3232

3333
dev_dependencies:
3434
flutter_lints: ^1.0.4

0 commit comments

Comments
 (0)