From 2db062fa3fbe77fe2956a547be699ce5ea6e2eb7 Mon Sep 17 00:00:00 2001 From: Maurits van Beusekom Date: Wed, 27 Mar 2024 12:02:59 +0100 Subject: [PATCH] Updates the README for the new location permissions. (#1297) * Updates the README for the new location permissions * Update permission_handler/CHANGELOG.md Co-authored-by: TimHoogstrate --------- Co-authored-by: TimHoogstrate --- permission_handler/CHANGELOG.md | 4 + permission_handler/README.md | 148 ++++++++++++++++---------------- permission_handler/pubspec.yaml | 4 +- 3 files changed, 80 insertions(+), 76 deletions(-) diff --git a/permission_handler/CHANGELOG.md b/permission_handler/CHANGELOG.md index 070b194c9..65b8ef989 100644 --- a/permission_handler/CHANGELOG.md +++ b/permission_handler/CHANGELOG.md @@ -1,3 +1,7 @@ +## 11.3.1 + +* Documents the use of the `PERMISSION_LOCAITON_WHENINUSE` macro on iOS. + ## 11.3.0 * Adds a new permission `Permission.backgroundRefresh` to check the background refresh permission status via: diff --git a/permission_handler/README.md b/permission_handler/README.md index b0beb2c24..fb1e61d2c 100644 --- a/permission_handler/README.md +++ b/permission_handler/README.md @@ -14,7 +14,7 @@ See the [FAQ](#faq) section for more information on common questions when using While the permissions are being requested during runtime, you'll still need to tell the OS which permissions your app might potentially use. That requires adding permission configuration to Android* and iOS-specific files.
-Android +Android (click to expand) **Upgrade pre-1.12 Android projects** @@ -52,7 +52,7 @@ In general, it's sufficient to add permission only to the `main` version.
-iOS +iOS (click to expand) Add permission to your `Info.plist` file. [Here](https://github.com/Baseflow/flutter-permission-handler/blob/master/permission_handler/example/ios/Runner/Info.plist)'s an example `Info.plist` with a complete list of all possible permissions. @@ -65,78 +65,76 @@ You must list the permission you want to use in your application: 1. Add the following to your `Podfile` file: - ```ruby - post_install do |installer| - installer.pods_project.targets.each do |target| - ... # Here are some configurations automatically generated by flutter - - # Start of the permission_handler configuration - target.build_configurations.each do |config| - - # You can enable the permissions needed here. For example to enable camera - # permission, just remove the `#` character in front so it looks like this: - # - # ## dart: PermissionGroup.camera - # 'PERMISSION_CAMERA=1' - # - # Preprocessor definitions can be found at: https://github.com/Baseflow/flutter-permission-handler/blob/master/permission_handler_apple/ios/Classes/PermissionHandlerEnums.h - config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [ - '$(inherited)', - - ## dart: [PermissionGroup.calendarWriteOnly, PermissionGroup.calendar (iOS 16 and below)] - # 'PERMISSION_EVENTS=1', - - ## dart: [PermissionGroup.calendarFullAccess, PermissionGroup.calendar (iOS 17 and above)] - # 'PERMISSION_EVENTS_FULL_ACCESS=1', - - ## dart: PermissionGroup.reminders - # 'PERMISSION_REMINDERS=1', + ```ruby + post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) - ## dart: PermissionGroup.contacts - # 'PERMISSION_CONTACTS=1', + target.build_configurations.each do |config| + # You can remove unused permissions here + # for more information: https://github.com/BaseflowIT/flutter-permission-handler/blob/master/permission_handler/ios/Classes/PermissionHandlerEnums.h + # e.g. when you don't need camera permission, just add 'PERMISSION_CAMERA=0' + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [ + '$(inherited)', - ## dart: PermissionGroup.camera - # 'PERMISSION_CAMERA=1', + ## dart: PermissionGroup.calendar + 'PERMISSION_EVENTS=1', + + ## dart: PermissionGroup.calendarFullAccess + 'PERMISSION_EVENTS_FULL_ACCESS=1', - ## dart: PermissionGroup.microphone - # 'PERMISSION_MICROPHONE=1', + ## dart: PermissionGroup.reminders + 'PERMISSION_REMINDERS=1', - ## dart: PermissionGroup.speech - # 'PERMISSION_SPEECH_RECOGNIZER=1', + ## dart: PermissionGroup.contacts + 'PERMISSION_CONTACTS=1', - ## dart: PermissionGroup.photos - # 'PERMISSION_PHOTOS=1', + ## dart: PermissionGroup.camera + 'PERMISSION_CAMERA=1', - ## dart: PermissionGroup.photosAddOnly - # 'PERMISSION_PHOTOS_ADD_ONLY=1', + ## dart: PermissionGroup.microphone + 'PERMISSION_MICROPHONE=1', - ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse] - # 'PERMISSION_LOCATION=1', + ## dart: PermissionGroup.speech + 'PERMISSION_SPEECH_RECOGNIZER=1', - ## dart: PermissionGroup.notification - # 'PERMISSION_NOTIFICATIONS=1', + ## dart: PermissionGroup.photos + 'PERMISSION_PHOTOS=1', - ## dart: PermissionGroup.mediaLibrary - # 'PERMISSION_MEDIA_LIBRARY=1', + ## The 'PERMISSION_LOCATION' macro enables the `locationWhenInUse` and `locationAlways` permission. If + ## the application only requires `locationWhenInUse`, only specify the `PERMISSION_LOCATION_WHENINUSE` + ## macro. + ## + ## dart: [PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse] + 'PERMISSION_LOCATION=1', + 'PERMISSION_LOCATION_WHENINUSE=0', - ## dart: PermissionGroup.sensors - # 'PERMISSION_SENSORS=1', + ## dart: PermissionGroup.notification + 'PERMISSION_NOTIFICATIONS=1', - ## dart: PermissionGroup.bluetooth - # 'PERMISSION_BLUETOOTH=1', + ## dart: PermissionGroup.mediaLibrary + 'PERMISSION_MEDIA_LIBRARY=1', - ## dart: PermissionGroup.appTrackingTransparency - # 'PERMISSION_APP_TRACKING_TRANSPARENCY=1', + ## dart: PermissionGroup.sensors + 'PERMISSION_SENSORS=1', - ## dart: PermissionGroup.criticalAlerts - # 'PERMISSION_CRITICAL_ALERTS=1' - ] + ## dart: PermissionGroup.bluetooth + 'PERMISSION_BLUETOOTH=1', - end - # End of the permission_handler configuration - end - end - ``` + ## dart: PermissionGroup.appTrackingTransparency + 'PERMISSION_APP_TRACKING_TRANSPARENCY=1', + + ## dart: PermissionGroup.criticalAlerts + 'PERMISSION_CRITICAL_ALERTS=1', + + ## dart: PermissionGroup.criticalAlerts + 'PERMISSION_ASSISTANT=1', + ] + + end + end + end + ``` 2. Remove the `#` character in front of the permission you want to use. For example, if you need access to the calendar make sure the code looks like this: @@ -149,21 +147,23 @@ You must list the permission you want to use in your application: e.g. when you don't need camera permission, just delete 'NSCameraUsageDescription' The following lists the relationship between `Permission` and `The key of Info.plist`: -| Permission | Info.plist | Macro | -|-------------------------------------------------------------------------------------------| ------------------------------------------------------------------------------------------------------------- | ------------------------------------ | -| PermissionGroup.calendar (< iOS 17) | NSCalendarsUsageDescription | PERMISSION_EVENTS | -| PermissionGroup.calendarWriteOnly (iOS 17+) | NSCalendarsWriteOnlyAccessUsageDescription | PERMISSION_EVENTS | -| PermissionGroup.calendarFullAccess (iOS 17+) | NSCalendarsFullAccessUsageDescription | PERMISSION_EVENTS_FULL_ACCESS | -| PermissionGroup.reminders | NSRemindersUsageDescription | PERMISSION_REMINDERS | -| PermissionGroup.contacts | NSContactsUsageDescription | PERMISSION_CONTACTS | -| PermissionGroup.camera | NSCameraUsageDescription | PERMISSION_CAMERA | -| PermissionGroup.microphone | NSMicrophoneUsageDescription | PERMISSION_MICROPHONE | -| PermissionGroup.speech | NSSpeechRecognitionUsageDescription | PERMISSION_SPEECH_RECOGNIZER | -| PermissionGroup.photos | NSPhotoLibraryUsageDescription | PERMISSION_PHOTOS | -| PermissionGroup.photosAddOnly | NSPhotoLibraryAddUsageDescription | PERMISSION_PHOTOS_ADD_ONLY | +| Permission | Info.plist | Macro | +|---------------------------------------------------------------------------------------------| ------------------------------------------------------------------------------------------------------------- | ------------------------------------ | +| PermissionGroup.calendar (< iOS 17) | NSCalendarsUsageDescription | PERMISSION_EVENTS | +| PermissionGroup.calendarWriteOnly (iOS 17+) | NSCalendarsWriteOnlyAccessUsageDescription | PERMISSION_EVENTS | +| PermissionGroup.calendarFullAccess (iOS 17+) | NSCalendarsFullAccessUsageDescription | PERMISSION_EVENTS_FULL_ACCESS | +| PermissionGroup.reminders | NSRemindersUsageDescription | PERMISSION_REMINDERS | +| PermissionGroup.contacts | NSContactsUsageDescription | PERMISSION_CONTACTS | +| PermissionGroup.camera | NSCameraUsageDescription | PERMISSION_CAMERA | +| PermissionGroup.microphone | NSMicrophoneUsageDescription | PERMISSION_MICROPHONE | +| PermissionGroup.speech | NSSpeechRecognitionUsageDescription | PERMISSION_SPEECH_RECOGNIZER | +| PermissionGroup.photos | NSPhotoLibraryUsageDescription | PERMISSION_PHOTOS | +| PermissionGroup.photosAddOnly | NSPhotoLibraryAddUsageDescription | PERMISSION_PHOTOS_ADD_ONLY | | PermissionGroup.location, PermissionGroup.locationAlways, PermissionGroup.locationWhenInUse | NSLocationUsageDescription, NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationWhenInUseUsageDescription | PERMISSION_LOCATION | -| PermissionGroup.notification | PermissionGroupNotification | PERMISSION_NOTIFICATIONS | -| PermissionGroup.mediaLibrary | NSAppleMusicUsageDescription, kTCCServiceMedia +| PermissionGroup.locationWhenInUse | NSLocationWhenInUseUsageDescription | PERMISSION_LOCATION_WHENINUSE | +| PermissionGroup.notification | PermissionGroupNotification | PERMISSION_NOTIFICATIONS | +| PermissionGroup.mediaLibrary | NSAppleMusicUsageDescription, kTCCServiceMedia | +PERMISSION_MEDIA_LIBRARY | 4. Clean & Rebuild diff --git a/permission_handler/pubspec.yaml b/permission_handler/pubspec.yaml index c6be8ee07..e74fa4bf9 100644 --- a/permission_handler/pubspec.yaml +++ b/permission_handler/pubspec.yaml @@ -2,7 +2,7 @@ name: permission_handler description: Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) 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: 11.3.0 +version: 11.3.1 environment: @@ -26,7 +26,7 @@ dependencies: sdk: flutter meta: ^1.7.0 permission_handler_android: ^12.0.3 - permission_handler_apple: ^9.4.0 + permission_handler_apple: ^9.4.3 permission_handler_html: ^0.1.1 permission_handler_windows: ^0.2.1 permission_handler_platform_interface: ^4.2.0