deniza / app_tracking_transparency

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

The library doesn't work ! #15

Closed stonekase closed 2 years ago

stonekase commented 3 years ago

I had my app reject for no reason as this library doesnt come up with any pop-up or request for permission on a real device.

deniza commented 3 years ago

Which iOS version do you use? I just build it using Xcode 12.4 and tested on a real device with iOS version 14.4.2. Everything seems working fine.

mnc12004 commented 3 years ago

I have the same issue as stonekase. I have updated to Flutter 2.2, using the latest Google Ads and no popup requesting permission.

Im at a loss! The Android version of my app is fine and live, yet the Apple one is delayed because I can't get permissions dialog.

HELP!

deniza commented 3 years ago

Hi,

Do you test it on a real device or on xcode simulator? What is happening after you call: AppTrackingTransparency.requestTrackingAuthorization();

If you run your tests on a simulator please check debug output (xcode debug area).

I am running my tests both on a device running ios 14.5 and on xcode simulator using flutter 2.0.6. Everything seems fine.

mnc12004 commented 3 years ago

Hi Deniza, Tested on a real device.

So, I got the dialog to show by doing a few things.

First, runApp(MaterialApp(home: MyApp())); changed from runApp(MyApp());

Second: worked out that TrackingStatus.restricted was the current state, so created an if block to deal with that:

  if (await status == TrackingStatus.restricted ) {
    print('Should Show Dialog');
    if (await showCustomTrackingDialog(context)) {
      // Wait for dialog popping animation
      await Future.delayed(const Duration(milliseconds: 200));
      // Request system's tracking authorization dialog
      final TrackingStatus status =
          await AppTrackingTransparency.requestTrackingAuthorization();
      setState(() => _authStatus = '$status');
    }
  }

But, when the dialog opens and I click on Allow Tracking, the dialog disappears, which os great but I don't think the TrackingStatus is being set, because, if I close the app and re-open it, the dialog shows again, which is not expected if I've accepted the tracking.

Is there meant to be a system dialog showing? If so, it's not.

I am using an iPhone 11 with Software 14.5. Flutter is 2.2 stable

deniza commented 3 years ago

Your test device seems stuck in restricted mode and can not show native authorization dialogue. Please read below for more information on this topic. You may need to alter your devices settings. https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager/authorizationstatus/restricted

Our library shows a custom explainer dialogue before showing the native apple consent dialogue. TrackingStatus.notDetermined means that the user has not yet received a request to authorize IDFA access, so we can show the native consent dialogue. With this info on our pocket, we show our custom explainer dialogue first, then the native auth dialogue. You should not try to change this flow.

Hope that I cleared some confusion on this subject.

mnc12004 commented 3 years ago

Hi Deniza, Thanks for your reply. I appreciate all of your work on this issue. I will look into my devices restricted status. However, when I submit the build to Apple, they are getting the same problem and will not approve my app for sale.

I'm certainly not saying your package is no good, I'm trying to get it to work.

And yep, my ios device is managed by the company and tracking is disabled and I can't turn it on. :(

I will get the simulator working and let you know.

deniza commented 3 years ago

Be sure to test it on the latest version of xcode, which is 12.5 at this time.

Its is better to create a new flutter project, then copy & paste example from https://pub.dev/packages/app_tracking_transparency/example to your lib/main.dart and test it on a device or simulator as is. Also don't forget to define NSUserTrackingUsageDescription in your Info.plist.

If everything is working as expected try to integrate it into your own project. Good luck.

mnc12004 commented 3 years ago

Ive done all that. One thing I noticed and I'm about to try is that before I changed runApp and tried to run a web build it would build ok but not instantiate FirebaseApp(). Im going to try that now since i've changed runApp and the dialog works sort of. I will remove my code too.

Let you know how it goes.

mnc12004 commented 3 years ago

Hi Deniza, Changing runApp(MyApp()); to runApp(MaterialApp(home: MyApp())); seems to have done the trick. Well at least on a simulator device.

My iPhone 11 is managed by work and yep, App Tracking is disabled and cannot be changed. Thanks for opening my eyes to that issue.

I'm uploading to Apple now, so will see if the app passes now.

Fingers crossed....

mnc12004 commented 3 years ago

Phew! what a nightmare!

Not this package by the way, Apple's app review process...

Anyway, the app finally passed and is live again now.

So my issue was a code base from an earlier build and not picking up the change in runApp(). Once that was changed everything works fine.

Thanks loads Deniz for your patience and this package.