Commit 7307fe0c by JDDV

Added AppTrackingTransparency permission

parent ebe31370
## 7.3.0
* Added support for the "AppTrackingTransparency" permission on iOS.
## 7.2.0 ## 7.2.0
* Added support for the "REQUEST_INSTALL_PACKAGES" permission on Android. * Added support for the "REQUEST_INSTALL_PACKAGES" permission on Android.
......
...@@ -41,54 +41,35 @@ ...@@ -41,54 +41,35 @@
</array> </array>
<key>UIViewControllerBasedStatusBarAppearance</key> <key>UIViewControllerBasedStatusBarAppearance</key>
<false/> <false/>
<key>NSLocationWhenInUseUsageDescription</key>
<!-- Permission options for the `location` group --> <string>Need location when in use</string>
<key>NSLocationWhenInUseUsageDescription</key> <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Need location when in use</string> <string>Always and when in use!</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key> <key>NSLocationUsageDescription</key>
<string>Always and when in use!</string> <string>Older devices need location.</string>
<key>NSLocationUsageDescription</key> <key>NSLocationAlwaysUsageDescription</key>
<string>Older devices need location.</string> <string>Can I have location always?</string>
<key>NSLocationAlwaysUsageDescription</key> <key>NSAppleMusicUsageDescription</key>
<string>Can I have location always?</string> <string>Music!</string>
<key>kTCCServiceMediaLibrary</key>
<!-- Permission options for the `mediaLibrary` group --> <string>media</string>
<key>NSAppleMusicUsageDescription</key> <key>NSCalendarsUsageDescription</key>
<string>Music!</string> <string>Calendars</string>
<key>kTCCServiceMediaLibrary</key> <key>NSCameraUsageDescription</key>
<string>media</string> <string>camera</string>
<key>NSContactsUsageDescription</key>
<!-- Permission options for the `calendar` group --> <string>contacts</string>
<key>NSCalendarsUsageDescription</key> <key>NSMicrophoneUsageDescription</key>
<string>Calendars</string> <string>microphone</string>
<key>NSSpeechRecognitionUsageDescription</key>
<!-- Permission options for the `camera` group --> <string>speech</string>
<key>NSCameraUsageDescription</key> <key>NSMotionUsageDescription</key>
<string>camera</string> <string>motion</string>
<key>NSPhotoLibraryUsageDescription</key>
<!-- Permission options for the `contacts` group --> <string>photos</string>
<key>NSContactsUsageDescription</key> <key>NSRemindersUsageDescription</key>
<string>contacts</string> <string>reminders</string>
<key>NSUserTrackingUsageDescription</key>
<!-- Permission options for the `microphone` group --> <string>appTrackingTransparency</string>
<key>NSMicrophoneUsageDescription</key>
<string>microphone</string>
<!-- Permission options for the `speech` group -->
<key>NSSpeechRecognitionUsageDescription</key>
<string>speech</string>
<!-- Permission options for the `sensors` group -->
<key>NSMotionUsageDescription</key>
<string>motion</string>
<!-- Permission options for the `photos` group -->
<key>NSPhotoLibraryUsageDescription</key>
<string>photos</string>
<!-- Permission options for the `reminder` group -->
<key>NSRemindersUsageDescription</key>
<string>reminders</string>
</dict> </dict>
</plist> </plist>
...@@ -50,7 +50,8 @@ class _PermissionHandlerWidgetState extends State<PermissionHandlerWidget> { ...@@ -50,7 +50,8 @@ class _PermissionHandlerWidgetState extends State<PermissionHandlerWidget> {
permission != Permission.mediaLibrary && permission != Permission.mediaLibrary &&
permission != Permission.photos && permission != Permission.photos &&
permission != Permission.photosAddOnly && permission != Permission.photosAddOnly &&
permission != Permission.reminders; permission != Permission.reminders &&
permission != Permission.appTrackingTransparency;
} }
}) })
.map((permission) => PermissionWidget(permission)) .map((permission) => PermissionWidget(permission))
......
...@@ -95,6 +95,13 @@ ...@@ -95,6 +95,13 @@
#define PERMISSION_BLUETOOTH 1 #define PERMISSION_BLUETOOTH 1
#endif #endif
// ios: PermissionGroupAppTrackingTransparency
// Info.plist: [NSUserTrackingUsageDescription]
// dart: PermissionGroup.appTrackingTransparency
#ifndef PERMISSION_APP_TRACKING_TRANSPARENCY
#define PERMISSION_APP_TRACKING_TRANSPARENCY 1
#endif
typedef NS_ENUM(int, PermissionGroup) { typedef NS_ENUM(int, PermissionGroup) {
PermissionGroupCalendar = 0, PermissionGroupCalendar = 0,
PermissionGroupCamera, PermissionGroupCamera,
...@@ -119,7 +126,9 @@ typedef NS_ENUM(int, PermissionGroup) { ...@@ -119,7 +126,9 @@ typedef NS_ENUM(int, PermissionGroup) {
PermissionGroupUnknown, PermissionGroupUnknown,
PermissionGroupBluetooth, PermissionGroupBluetooth,
PermissionGroupManageExternalStorage, PermissionGroupManageExternalStorage,
PermissionGroupSystemAlertWindow PermissionGroupSystemAlertWindow,
PermissionGroupRequestInstallPackages,
PermissionGroupAppTrackingTransparency
}; };
typedef NS_ENUM(int, PermissionStatus) { typedef NS_ENUM(int, PermissionStatus) {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "AudioVideoPermissionStrategy.h" #import "AudioVideoPermissionStrategy.h"
#import "AppTrackingTransparencyPermissionStrategy.h"
#import "BluetoothPermissionStrategy.h" #import "BluetoothPermissionStrategy.h"
#import "ContactPermissionStrategy.h" #import "ContactPermissionStrategy.h"
#import "EventPermissionStrategy.h" #import "EventPermissionStrategy.h"
......
...@@ -125,6 +125,8 @@ ...@@ -125,6 +125,8 @@
return [StoragePermissionStrategy new]; return [StoragePermissionStrategy new];
case PermissionGroupBluetooth: case PermissionGroupBluetooth:
return [BluetoothPermissionStrategy new]; return [BluetoothPermissionStrategy new];
case PermissionGroupAppTrackingTransparency:
return [AppTrackingTransparencyPermissionStrategy new];
default: default:
return [UnknownPermissionStrategy new]; return [UnknownPermissionStrategy new];
} }
......
//
// AppTrackingTransparency.h
// permission_handler
//
// Created by Jan-Derk on 21/05/2021.
//
#import <Foundation/Foundation.h>
#import "PermissionStrategy.h"
#if PERMISSION_APP_TRACKING_TRANSPARENCY
#import <AppTrackingTransparency/AppTrackingTransparency.h>
@interface AppTrackingTransparencyPermissionStrategy : NSObject <PermissionStrategy>
@end
#else
#import "UnknownPermissionStrategy.h"
@interface AppTrackingTransparencyPermissionStrategy : UnknownPermissionStrategy
@end
#endif
//
// AppTrackingTransparency.m
// permission_handler
//
// Created by Jan-Derk on 21/05/2021.
//
#import "AppTrackingTransparencyPermissionStrategy.h"
#if PERMISSION_APP_TRACKING_TRANSPARENCY
@implementation AppTrackingTransparencyPermissionStrategy
- (PermissionStatus)checkPermissionStatus:(PermissionGroup)permission {
if (@available(iOS 14, *)) {
ATTrackingManagerAuthorizationStatus attPermission = [ATTrackingManager trackingAuthorizationStatus];
return [AppTrackingTransparencyPermissionStrategy parsePermission:attPermission];
}
return PermissionStatusGranted;
}
- (ServiceStatus)checkServiceStatus:(PermissionGroup)permission {
return ServiceStatusNotApplicable;
}
- (void)requestPermission:(PermissionGroup)permission completionHandler:(PermissionStatusHandler)completionHandler {
PermissionStatus status = [self checkPermissionStatus:permission];
if (status != PermissionStatusDenied) {
completionHandler(status);
return;
}
if (@available(iOS 14, *)){
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
PermissionStatus permissionStatus = [AppTrackingTransparencyPermissionStrategy parsePermission:status];
completionHandler(permissionStatus);
}];
} else {
completionHandler(PermissionStatusGranted);
}
}
+ (PermissionStatus)parsePermission:(ATTrackingManagerAuthorizationStatus)attPermission API_AVAILABLE(ios(14)){
switch(attPermission){
case ATTrackingManagerAuthorizationStatusAuthorized:
return PermissionStatusGranted;
case ATTrackingManagerAuthorizationStatusRestricted:
return PermissionStatusRestricted;
case ATTrackingManagerAuthorizationStatusDenied:
return PermissionStatusPermanentlyDenied;
case ATTrackingManagerAuthorizationStatusNotDetermined:
return PermissionStatusDenied;
}
}
@end
#else
@implementation AppTrackingTransparencyPermissionStrategy
@end
#endif
name: permission_handler name: permission_handler
description: Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions. description: Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
version: 7.2.0 version: 7.3.0
homepage: https://github.com/baseflowit/flutter-permission-handler homepage: https://github.com/baseflowit/flutter-permission-handler
flutter: flutter:
...@@ -16,7 +16,7 @@ dependencies: ...@@ -16,7 +16,7 @@ dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
meta: ^1.3.0 meta: ^1.3.0
permission_handler_platform_interface: ^3.4.0 permission_handler_platform_interface: ^3.5.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment