IDFA is an abbreviation for "Identifier for Advertisers", a device ID that Apple randomly assigns to a user's device. Advertisers can use this ID to measure user ad engagement and in-app user behavior to serve customized ads. In other words, it is thanks to this IDFA that you may see ads that you are interested in in the iOS app.
At WWDC 2020, it was announced that iOS 14 will make changes to the handling of IDFA. Since iOS14, it is required to display a dialog to select whether to acquire IDFA before acquiring it.
Add the following framework. AdSupport.framework AppTrackingTransparency.framework
Reference link: https://developer.apple.com/documentation/adsupport https://developer.apple.com/documentation/apptrackingtransparency
Set the wording in Value with "Privacy --Tracking Usage Description" as the Key in info.plist. The wording is reflected in the red frame part of the above image, and it seems that the default wording cannot be changed for other parts.
By using ** requestTrackingAuthorization (completionHandler :) ** to display the dialog, it can be implemented as follows.
Swift
if #available(iOS 14, *) {
ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
switch status {
case .authorized:
//IDFA acquisition
print("IDFA: \(ASIdentifierManager.shared().advertisingIdentifier)")
print("success")
case .denied, .restricted, .notDetermined:
print("failure")
@unknown default:
fatalError()
}
})
}
Recommended Posts