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

ATT Not working on IOS 15.0 #22

Closed alixumer closed 2 years ago

alixumer commented 2 years ago

We have got a message from app store.

" We're looking forward to completing our review, but we need more information to continue. Your app uses the AppTrackingTransparency framework, but we are unable to locate the App Tracking Transparency permission request when reviewed on iOS 15.0.

Since you indicated in App Store Connect that you collect data in order to track the user, we need to confirm that App Tracking Transparency has been correctly implemented "

Kindly update the plugin as soon as possible. Thank You

deniza commented 2 years ago

I just compiled the example using xcode 13 and tested it on ios 15 simulator. Everything seems running fine. As I do not have any ios devices running ios 15, I cannot test it on a real device right now. Do you have any chance to test the example on an ios 15 device?

deniza commented 2 years ago

Oh, and please update the plugin to version 2.0.2+1 to fix a nasty bug regarding to null safety in example.

alixumer commented 2 years ago

Thank you so much for your response. I have updated the version, now it is working fine. Also i have tested it on a real device with IOS 15.0, it is working.

jodymac commented 2 years ago

I just got this as well. However, simply updating the plugin and reloading on ios 15 didn't solve the issue. I had to actually move the location where I called the plugin. I was calling it in an init that only runs after checking if it's first run, where it's always been since I started using it. Now it won't run event though the method is called. I moved it to the end of my onboarding and now it works just fine. So if you run across this and the above doesn't fix it. Try calling the the check at a different time.

I am calling WidgetsFlutterBinding.ensureInitialized(); and MobileAds.instance.initialize(); in my main.dart. It's completely possible that playing with these could have been a solution as well. For some reason, the plugin just wasn't firing like it did before. I also had onesignal firing about the same time, that continued to work the same.

Eittipat commented 2 years ago

I have this problem too

Zazell commented 2 years ago

I'm running in the same problem; What i found is that the plugin isn't prompting for the permission and that it returns a restricted status, upon checking this in the Tracking screen in iOS, it mentions there that the setting cannot be enabled because my Apple ID is missing age information (being 40+ and the birthdate is in my apple ID, this sounds like an issue with iOS to me...)

No real solution found yet, except logging out of my apple ID and then it works...

yacineblr commented 2 years ago

Same problem on my side, a solution has been found?

ipapps commented 2 years ago

Seems that, starting with iOS 15, there is a problem prompting two consecutive native popups. Especially, if you prompt at around the same time (at startup probably), the notification authorization prompt, then your ATT prompt will be squashed.

On a project of mine (a native iOS one), I had to do this to overcome this problem :

    func applicationDidBecomeActive(_ application: UIApplication) {
        if #available(iOS 14, *) {
            ATTrackingManager.requestTrackingAuthorization { status in
                switch status {
                case .authorized:
                    Settings.setAdvertiserTrackingEnabled(true)
                case .denied:
                    Settings.setAdvertiserTrackingEnabled(false)
                case .notDetermined: break
                case .restricted:
                    Settings.setAdvertiserTrackingEnabled(false)
                @unknown default: break
                }
            }
        }
    }

Moving the ATTrackingManager to applicationDidBecomeActive instead of the more common application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?)

yacineblr commented 2 years ago

Thanks for your reply @ipapps , That's exactly what I just did in addition to using the package to retrieve the user id. I sent back the app for apple submission, I just have to wait

Emicloud91 commented 2 years ago

Hi everyone, any solution on this issue?

walvespit commented 2 years ago

anyone? same problem here

jodymac commented 2 years ago

Please read all the posts on this, there are two solutions identified earlier. ipapps identification of the issue seems to be correct. My post above tells what I did to solve. In a nutshell, with ios 15, don't have back to back notifications fire consecutively.

deniza commented 2 years ago

You can also use a custom explainer dialog before calling AppTrackingTransparency.requestTrackingAuthorization(); ​ I guess this prevents consecutive popping dialogue problem @ipapps mentions.

Using this approach is also recommended by Google.

yacineblr commented 2 years ago

@walvespit Requesting authorization in the AppDelegate solved the problem, the verification is passed, and the app is available on the store

walvespit commented 2 years ago

@walvespit Requesting authorization in the AppDelegate solved the problem, the verification is passed, and the app is available on the store

Thank you for your answer, can you explain a little more please ? Where exactly is "in the AppDelegate" ?

yacineblr commented 2 years ago

in the file ios/Runner/AppDelegate.swift, I put this function in my class "AppDelegate" like this:

/// your import
import AppTrackingTransparency // add this

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    /// your code here
  }

  override func applicationDidBecomeActive(_ application: UIApplication) { // add this function
    if #available(iOS 14, *) {
      ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
          switch status {
          case .authorized:
              // Tracking authorization dialog was shown
              // and we are authorized
              print("Authorized")
          case .denied:
              // Tracking authorization dialog was
              // shown and permission is denied
              print("Denied")
          case .notDetermined:
              // Tracking authorization dialog has not been shown
              print("Not Determined")
          case .restricted:
              print("Restricted")
          @unknown default:
              print("Unknown")
          }
      })
    } else {
        //you got permission to track, iOS 14 is not yet installed
    }
  }
}

The tracking permission request will be the first to be displayed, then in flutter with the "app_tracking_transparency" package I check if the permission has been granted, if so, I get the identifier.

This is not the best method, but it allowed to pass the Apple verification