0

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

genericUser
  • 4,417
  • 1
  • 28
  • 73
  • Which version of iOS in your podFile, in this [answer here](https://stackoverflow.com/questions/63587364/how-to-add-the-apptrackingtransparency-permission-to-your-ios-apps) indicates an iOS 14 as a minimum for the dialog box to appear. – Chance Nov 29 '22 at 13:56
  • It seems that the MinimumOSVersion of the permission_handler is 9.0 – genericUser Nov 29 '22 at 14:01
  • The podfile `platform :ios {version}` is commented – genericUser Nov 29 '22 at 14:03
  • The permission_handler documentation does not mention that https://pub.dev/packages/permission_handler/versions/10.2.0 – genericUser Nov 29 '22 at 14:04
  • Yes, the handler doesn't indicate that, I'm talking based on the iOS permission. This permission is present only in iOS 14+, try to use this version as a minimum for your podfile. – Chance Nov 29 '22 at 14:21
  • But my ios device version is 15.2.1... so it should appear – genericUser Nov 29 '22 at 14:34

2 Answers2

0

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.

genericUser
  • 4,417
  • 1
  • 28
  • 73
0

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