deniza / app_tracking_transparency

A Flutter plugin to show ios 14+ tracking authorization dialog.
https://pub.dev/packages/app_tracking_transparency/
MIT License
83 stars 28 forks source link

requestTrackingAuthorization call returns immediately with denied value on iOS 17.4 #50

Open szepeshazi opened 4 months ago

szepeshazi commented 4 months ago

On iOS 17.4, the following call

// Show tracking authorization dialog and ask for permission
final status = await AppTrackingTransparency.requestTrackingAuthorization();

will display the prompt (if it was not displayed before) and will not wait for the prompt to be closed by user interaction, but rather returns immediately with a TrackingStatus.denied value. Once the prompt is closed by the user, on subsequent status checks the await AppTrackingTransparency.trackingAuthorizationStatus call will already return the proper value (as selected by the user).

Reproduced with version 2.0.4, on simulator (iPhone 15 / iOS 17.4) and real device (iPhone 13 mini / iOS 17.4)

fatihemree commented 4 months ago

Any progress? :(

waynepollen commented 4 months ago

Seeing the same thing

deniza commented 4 months ago

Very strange. I just re-tested with my device, iPhone 11 and ios 17.4. It's working as expected. The thing is; i am showing a dialog (an explainer dialog) before triggering the native dialog. In this setup user triggers the function call by pressing a button from a flutter dialog widget. This may be preventing any time-dependent bugs bugs underneath. I am just taking a wild guess here.

Can you please test this out on your own testing environment? Just call AppTrackingTransparency.requestTrackingAuthorization(); from a button event handler, not from a widget init function.

jamlo commented 4 months ago

My app submission was rejected by Apple yesterday because of this issue. They mention that the App Tracking Transparency request is not showing on iOS 17.4 . I am using version "2.0.4" of the package.

Though I am not able to reproduce the issue in my test environment using the same versions (both using a simulator or physical device). It is working as expected on my test environment.

Bilonik commented 4 months ago

@deniza getting the same bug even while using a button event handler, multiple Apple rejects, returns immediately with a TrackingStatus.denied value.

Bilonik commented 4 months ago

https://forums.developer.apple.com/forums/thread/748317

martiina commented 3 months ago

Having the same issue on iOS 17.3.1 and iOS 17.4. requestTrackingAuthorization returns immediately TrackingStatus.denied.

iPhone 12 Pro

Also, the callback is triggered with button. Same issue as @Bilonik has.

deniza commented 3 months ago

Looks like building the app with Xcode 15.4 might be causing issues. To test this, I created a sample app using Xcode 15.2 and ran it successfully on a real iPhone with iOS 17.4.

As a temporary workaround, try building with Xcode 15.2. The good news is you can have multiple Xcode versions installed at once. Just download Xcode 15.2 from the official Apple Developer Downloads: https://developer.apple.com/download/all/

Once downloaded, use the xcode-select command-line tool to switch to the newly installed version. Rebuild your Flutter app and then test it on a real device or simulator running iOS 17.4.

martiina commented 3 months ago

Hi. Thanks for the answer.

I ran with Xcode 15.3 previously. Don't even have access to 15.4

jamlo commented 3 months ago

Thanks @deniza for checking this.

Like @martiina, I am also using Xcode 15.3 when building the app, and the issue is happening when being reviewed by Apple.

Since the issue occurrence is inconsistent, it feels like a race condition, where the plugin is not appropriately waiting for a certain signal from Apple APIs?

xni06 commented 3 months ago

I reverted back to Xcode 15.2 (17.2) from 15.3 (17.4) using https://www.xcodes.app/ and it now works as expected again.

nmaruy27 commented 3 months ago

I was also rejected several times due to the same issue, but after making corrections based on the code in the comment below, it was successfully approved and I was able to release it.

https://github.com/deniza/app_tracking_transparency/issues/47#issuecomment-1751719988

deniza commented 3 months ago

Hi. Thanks for the answer.

I ran with Xcode 15.3 previously. Don't even have access to 15.4

Sorry, It's my bad. I tested it using Xcode 15.2 (not 15.3) and it's working as expected.

jamlo commented 3 months ago

FYI, even when I used Xcode 15.2 to build the app, it still had the same issue, and the app was rejected by Apple.

The following is the only solution that allowed the app to be accepted by Apple: https://github.com/deniza/app_tracking_transparency/issues/47#issuecomment-1746697074

onursahindur commented 3 months ago

Same here, still have the issue... Xcode 15.2, iOS 17.4.1 (real device)

adrian-fernandez commented 2 months ago

Seems to be an issue from Apple fixed on iOS 17.5 beta but not yet on 17.4.*

https://forums.developer.apple.com/forums/thread/746432

dionysos1 commented 2 months ago

untill this is fixed.

as the requestTrackingAuthorization returns isDenied but doesn't actually update the trackingStatus. I used a while loop to just check the status every second as you can't get around the request window as a user anyway.

/// Request system's tracking authorization dialog
  await AppTrackingTransparency.requestTrackingAuthorization();

  /// loop tracking status until it is no longer notDetermined
  while (await AppTrackingTransparency.trackingAuthorizationStatus == TrackingStatus.notDetermined) {
      await Future.delayed(const Duration(seconds: 1));
  }
  // code here that uses the actual status
EliseiNicolae commented 2 months ago

👋 hi there. I had the same issue on real device.

What worked for me was running the followings:

  1. Delete pod directory and podfile.lock
  2. flutter clean
  3. flutter pub get
  4. cd ios
  5. pod install --repo-update
  6. flutter build ios

And then deploy to testflight using Archive. After that test it by downloading the version from TestFlight

serk87 commented 2 months ago

Make sure you have Settings > Privacy > Tracking enabled

ervindobri commented 2 months ago

Any updates? Issue still persists

EliseiNicolae commented 2 months ago

👋 hi there. I had the same issue on real device. What worked for me was running the followings:

  1. Delete pod directory and podfile.lock
  2. flutter clean
  3. flutter pub get
  4. cd ios
  5. pod install --repo-update
  6. flutter build ios

And then deploy to testflight using Archive. After that test it by downloading the version from TestFlight

Thanks, but which Xcode version did you use? Does it work with Xcode15.3?

I think it was Xcode 15.2