가을기 Workspace

ios 15.1에서 app_tracking_transparency 관련 reject 먹을때 본문

개발/개인앱

ios 15.1에서 app_tracking_transparency 관련 reject 먹을때

가을기_ 2021. 12. 9. 22:33

 

 

 

 

ios/Runner/AppDelegate.swift 파일에 아래 코드 추가

/// your import
import AppTrackingTransparency // add this

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    /// your code here
  }

  override func applicationDidBecomeActive(_ application: UIApplication) { // add this function
    if #available(iOS 14, *) {
      ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
          switch status {
          case .authorized:
              // Tracking authorization dialog was shown
              // and we are authorized
              print("Authorized")
          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")
          }
      })
    } else {
        //you got permission to track, iOS 14 is not yet installed
    }
  }
}
Comments