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!
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.