Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ATTrackingManager stopped working in iOS 15

Tags:

swift

ios15

ATTrackingManager.requestTrackingAuthorization stopped working on ios 15. Application rejected from Apple.

like image 932
Tajinder singh Avatar asked Sep 24 '21 09:09

Tajinder singh


Video Answer


1 Answers

According to the discussion in Apple Developer Forum, you need to add delay for about one second when calling requestTrackingAuthorization. https://developer.apple.com/forums/thread/690607

Example:

DispatchQueue.main.asyncAfter(deadline: .now() + 1.0, execute: {
          ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
        // Tracking authorization completed. Start loading ads here.
        // loadAd()
      })
})

P.S. Also if you have requesting push notification permission, firstly you need request push notification then request tracking authorization with a delay =>

    private func requestPushNotificationPermission() {
    let center = UNUserNotificationCenter.current()
    UNUserNotificationCenter.current().delegate = self
    center.requestAuthorization(options: [.sound, .alert, .badge], completionHandler: { (granted, error) in
        if #available(iOS 14.0, *) {
            DispatchQueue.main.asyncAfter(deadline: .now() + 1.0, execute: {
                ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
                    // Tracking authorization completed. Start loading ads here.
                    // loadAd()
                })
            })
        }})
    UIApplication.shared.registerForRemoteNotifications()
}
like image 94
Okonov Urmat Avatar answered Oct 17 '22 16:10

Okonov Urmat