Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

// ...
import GFPSDK
import AdSupport
import AppTrackingTransparency
import BuzzvilSDK

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    // ...
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
      // initialize NAM
      GFPAdManager.setup(withPublisherCd: "YOUR_NAM_CODE", target: self) { error in
        if let error = error {
          // error
        }
      }
      
      // ...
    
    return true
  }
}

extension AppDelegate: GFPAdManagerDelegate {
  func attStatus() -> GFPATTAuthorizationStatus {
    if #available(iOS 14.5, *) {
      func convertATTrackingStatus(_ status: ATTrackingManager.AuthorizationStatus) -> GFPATTAuthorizationStatus {
        switch status {
        case .authorized:
          return .authorized
        case .denied:
          return .denied
        case .notDetermined:
          return .notDetermined
        case .restricted:
          return .restricted
        @unknown default:
          return .restricted
        }
      }
      return convertATTrackingStatus(ATTrackingManager.trackingAuthorizationStatus)
    } else {
      if ASIdentifierManager.shared().isAdvertisingTrackingEnabled {
        return .authorized
      }
      return .notDetermined
    }
  }
}
  • No labels