App Tracking Transparency Alert not Showing and status .notDetermined

Hey all, I have set the Privacy - Tracking Usage Description in my info.plist and have the following logic in my AppDelegate application(didFinishLaunching) func:

if #available(iOS 14, *) {
  if ATTrackingManager.trackingAuthorizationStatus == .notDetermined{
     requestIDFA()
  }
}

and the request func is as follows:

func requestIDFA() {
            ATTrackingManager.requestTrackingAuthorization( completionHandler: { status in
              print("Tracking Status:   ")
              switch status {
                  case .authorized:
                      print("authorized")
                  case .denied:
                      print("denied")
                  case .notDetermined:
                      print("not determined")
                  case .restricted:
                      print("restricted")
                  @unknown default:
                      print("defaulted?")
              }
            })
    }

However, the alert does not show on any device and the log prints:

Tracking Status: 
not determined

which, to my understanding, means the function is called and the request goes through, but the alert is never displayed and it assumes the answer of .notDetermined for some reason. I've searched all over and can't find anything that helps.

Any advice would be great appreciated. Thanks!

Answered by christopherhaas in 692131022

I finally found the solution. I believe I was calling it too early, as the requestIDFA function was called within the application("didFinishLaunchingWithOptions" ) in app delegate. If I moved the above logic to applicationDidBecomeActive function, still within the app delegate, it works. Hope this helps anyone who fell down this rabbit hole. It is weird that I previously got the popup to display through the initial approach in the beginning of development.

I can reproduce this issue in a macOS app

  • I have added NSUserTrackingUsageDescription to my info.plist
  • I call requestTrackingAuthorization(completionHandler:)

No dialog is shown, and trackingAuthorizationStatus remains "notDetermined"

Interestingly, System Preferences doesn't seem to have anything related to this.

  • macOS 11.6 Big Sur
  • Xcode 13.0 (13A233)

On iOS...

Settings > Privacy > Tracking

If the user turns off "Allow Apps to Request to Track"...
...then the dialog will never be shown...
...and "all new app tracking requests are automatically denied."

(This case must be considered, but presumably, this is not happening to you, as you still see "notDetermined")

NOTE: This is for an iOS 15 app

Accepted Answer

I finally found the solution. I believe I was calling it too early, as the requestIDFA function was called within the application("didFinishLaunchingWithOptions" ) in app delegate. If I moved the above logic to applicationDidBecomeActive function, still within the app delegate, it works. Hope this helps anyone who fell down this rabbit hole. It is weird that I previously got the popup to display through the initial approach in the beginning of development.

I was struggling with this for a while and this solution works for me. I am wondering though how did you figure it out? Is this documented somehow and I just did not understand it or is it just a quirk that everyone has to run into?

20 minutes later I have read the documentation once again. And this is clearly documented I just did not understand it:

"Calls to the API only prompt when the application state is UIApplicationStateActive." (https://developer.apple.com/documentation/apptrackingtransparency/attrackingmanager/3547037-requesttrackingauthorization)

sooooo frustrated and the worst part is I can not blame anyone else.

Well surely the rest of my day will not present me with frustrating obstacles. I mean coding rarely does. right...?

App Tracking Transparency Alert not Showing and status .notDetermined
 
 
Q