Reputation: 7188
I'm asking for tracking-transparency permission using the permission_handler in my app:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
Map<Permission, PermissionStatus> statuses = await [
Permission.photosAddOnly,
Permission.camera,
Permission.microphone,
Permission.appTrackingTransparency,
].request();
runApp(const MyApp());
}
All permission dialogs appear except for the appTrackingTransparency
one.
Why it doesn't show up?
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.7, on macOS 13.0 22A380 darwin-x64, locale en-IL)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.73.1)
[✓] Connected device (4 available)
[✓] HTTP Host Availability
device version: iOS 15.2.1
permission_handler: 10.0.0
Upvotes: 1
Views: 2774
Reputation: 21
You must list permission you want to use in your application
Inside your Podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
'PERMISSION_APP_TRACKING_TRANSPARENCY=1',
]
end
end
end
Upvotes: 2
Reputation: 7188
I decided to use the app_tracking_transparency. But the dialog still doesn't show up.
After reading about swift solutions, according to this post, adding a minor delay between dialogs seems to solve it.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await [
Permission.photosAddOnly,
Permission.camera,
Permission.microphone,
].request();
/// Getting permission for appTrackingTransparency required a delay between prompts.
if (await AppTrackingTransparency.trackingAuthorizationStatus ==
TrackingStatus.notDetermined) {
await Future.delayed(const Duration(seconds: 2));
await AppTrackingTransparency.requestTrackingAuthorization();
}
runApp(const MyApp());
}
Note: I don't know why, but it worked only with the app_tracking_transparency
package, but not with the permission_handler
package.
Still Looking for a better solution, using the permission_handler package, that does not delay the app load time.
Upvotes: 0