How to add the AppTrackingTransparency permission to your iOS apps How to add the AppTrackingTransparency permission to your iOS apps ios ios

How to add the AppTrackingTransparency permission to your iOS apps


For those who might be struggling with the same things, I got the AppTrackingTransparency dialog box to appear with the function,

import AppTrackingTransparencyimport AdSupport//NEWLY ADDED PERMISSIONS FOR iOS 14func requestPermission() {    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")            }        }    }}//

I then simply called the function requestPermission() on the app's login page, so users see the permission dialog before signing in. Without calling the function, the dialog box show in this guide, https://developers.google.com/admob/ios/ios14, doesn't appear for me.

This article has an example github project: https://medium.com/@nish.bhasin/how-to-get-idfa-in-ios14-54f7ea02aa42


In iOS 15 it can only be requested with ATTrackingManager.requestTrackingAuthorization if the application state is already active, so it should be moved from didFinishLaunchingWithOptions to applicationDidBecomeActive.


What's happen if the user doesn't give tracking permission to the app? then when the user doesn't allow tracking permission, you can't get IDFA then Your revenue will be down again...for more see Answer

To Solve itthe Google Mobile Ads SDK supports conversion tracking using Apple's SKAdNetwork, which lets Google attribute an app install even when the IDFA is not available.

SKAdNetwork Solutions for Advertisers to Get out-of-the-box support for Appleā€™s SKAdNetwork and maximize your future growth on iOS 14 & beyond.

To fix it, enable SKAdNetwork to track conversions

The Google Mobile Ads SDK supports conversion tracking using Apple's SKAdNetwork, which lets Google attribute an app install even when the IDFA is not available.

To enable this functionality, update the SKAdNetworkItems key with an additional dictionary that defines Google's SKAdNetworkIdentifier value in your Info.plist.

    <key>SKAdNetworkItems</key>  <array>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>cstr6suwn9.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>4fzdc2evr5.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>2fnua5tdw4.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>ydx93a7ass.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>5a6flpkh64.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>p78axxw29g.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>v72qych5uu.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>c6k4g5qg8m.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>s39g8k73mm.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>3qy4746246.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>3sh42y64q3.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>f38h382jlk.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>hs6bdukanm.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>prcb7njmu6.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>wzmmz9fp6w.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>yclnxrl5pm.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>4468km3ulz.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>t38b2kh725.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>7ug5zh24hu.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>9rd848q2bz.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>n6fk4nfna4.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>kbd757ywx3.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>9t245vhmpl.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>2u9pt9hc89.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>8s468mfl3y.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>av6w8kgt66.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>klf5c3l5u5.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>ppxm28t8ap.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>424m5254lk.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>uw77j35x4d.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>e5fvkxwrpn.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>zq492l623r.skadnetwork</string>    </dict>    <dict>      <key>SKAdNetworkIdentifier</key>      <string>3qcr597p9d.skadnetwork</string>    </dict>  </array>