ATTrackingManager.requestTrackingAuthorization always returns "Not Determined" and prompt is never shown

Hi,

I have read all exisiting posts about this topic, but until now I can not get it to work.

Somehow calling ATTrackingManager.requestTrackingAuthorization  never shows the popup.

I added Privacy - Tracking Usage Description to the info list. I also turned on the system permissions.

I am developing the app with SwiftUI. Target device runs ios 15.4 Any ideas?

Code:




    DeckListView(decks: $store.decks){
             Task {
                  ....
            }
        }
      }.onAppear{
        requestPermission()
      }


   func requestPermission() {
    DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
      if #available(iOS 14, *) {

          ATTrackingManager.requestTrackingAuthorization { status in
          switch status {
          case .authorized:
            // Tracking authorization dialog was shown
            // and we are authorized
            print("Authorized")
             
            // Now that we are authorized we can get the IDFA
            print(ASIdentifierManager.shared().advertisingIdentifier)
          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")
          }
        }
      }
       
    }

  }
Answered by TRCat in 708038022

Finally I found the source of my problem. I accidentally called ATTrackingManager.requestTrackingAuthorization twice. The first time I called while the app was not in an active state. It seems, if the first call is made outside active state, any other calls will no longer show the popup.

Accepted Answer

Finally I found the source of my problem. I accidentally called ATTrackingManager.requestTrackingAuthorization twice. The first time I called while the app was not in an active state. It seems, if the first call is made outside active state, any other calls will no longer show the popup.

ATTrackingManager.requestTrackingAuthorization always returns "Not Determined" and prompt is never shown
 
 
Q