Can I get idfa without calling AppTrackingTransparency frameworks using xcode12 on ios14

I use xcode12 to compile and use the following code to get idfa on ios13.4 devices.

       if ASIdentifierManager.shared().isAdvertisingTrackingEnabled {
        let idfa = ASIdentifierManager.shared().advertisingIdentifier.uuidString
      }

But using the same code, no idfa can be obtained without calling ATT on IOS14 device.

Is this result correct? please confirm, thanks.



yes there's unable to get the IEFA though this method. You can try another one
That's right.
The method of obtaining IDFA has changed from iOS 14.
Use the App Tracking Transparency framework.
https://developer.apple.com/documentation/apptrackingtransparency

Set up a NSUserTrackingUsageDescription to display a system-permission alert request for your app installed on end-user devices.
How to setup:
https://developer.apple.com/documentation/bundleresources/information_property_list/nsusertrackingusagedescription

Then run the code below:

Code Block
import AppTrackingTransparency
struct UseATT {
func doThis() {
guard #available(iOS 14.0, *) else { return }
ATTrackingManager.requestTrackingAuthorization { status in
print("current status is \(status.rawValue).")
}
}
}


This is a modified version of the code.
Code Block swift
import AdSupport
import AppTrackingTransparency
struct UseATT {
    func doThis() {
        guard #available(iOS 14.0, *) else { return }
        ATTrackingManager.requestTrackingAuthorization { status in
            // Get IDFA here
            let idfa = ASIdentifierManager.shared().advertisingIdentifier.uuidString
            print("status = \(status.rawValue), idfa = \(idfa)")
        }
    }
}


Can I get idfa without calling AppTrackingTransparency frameworks using xcode12 on ios14
 
 
Q