Versions Compared

Key

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

...

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

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    // ...
    
    // initialize NAM
    GFPAdManager.setup(withPublisherCd: "7976096509YOUR_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
    }
  }
}