Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languageswift
// ...
import GFPSDK
import AdSupport
import AppTrackingTransparency
import AvatyeAdCashBuzzAdBenefit

@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
    }
  }
}