Attrackingmanager Stopped Working in iOS 15

App Tracking Transparency Dialog does not appear on iOS

Damn it I fixed it:( This is all about the iOS alert system. I was requesting App Tracking Transparency after a notification request was asked. Once the notification request alert closed, the ATT alert needed to have appeared. It was working fine on iOS 14, but on iOS 15 to display an alert right after another one, it is needed to have a delay period between each other.

Edit:
Here is my code that display two alert respectively:

 func setNotification(){
//Ask for notification permission
let n = NotificationHandler()
n.askNotificationPermission {
//n.scheduleAllNotifications()

//IMPORTANT: wait for 1 second to display another alert
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
if #available(iOS 14, *) {
ATTrackingManager.requestTrackingAuthorization { (status) in
//print("IDFA STATUS: \(status.rawValue)")
//FBAdSettings.setAdvertiserTrackingEnabled(true)
}
}
}
}
}

And for your convenience here is my NotificaitionHandler class:

import UserNotifications

class NotificationHandler{
//Permission function
func askNotificationPermission(completion: @escaping ()->Void){

//Permission to send notifications
let center = UNUserNotificationCenter.current()
// Request permission to display alerts and play sounds.
center.requestAuthorization(options: [.alert, .badge, .sound])
{ (granted, error) in
// Enable or disable features based on authorization.
completion()
}
}

ATTrackingManager.requestTrackingAuthorization completion status returns notDetermined

It is essentially duplicate to the question you linked to in that root cause is the same.

The problem is you are asking the system to display the consent dialog before there is a view controller that the dialog can be presented from.

The earliest you can display the tracking consent dialog is in viewDidAppear of your first view controller, since at that point you know that there is a view controller visible on screen.

The answer in the question you linked to avoids the problem by dispatching the tracking request after a short delay which gives enough time for the initial view controller to be presented.

I am not a big fan of this sort of fix, but you can use it if you like.

A better solution is to move your tracking consent into an appropriate object and invoke a method on that object in your first view controller.

IDFA iOS14 returns denied without displaying auth popup

There's an option "Allow Apps to Request to Track" in system's Settings app, and if it's off, requestTrackingAuthorization will return .denied immediately.

Privacy Setting

ATTrackingManager.requestTrackingAuthorization always returns Not Determined and prompt is never shown

Finally I found the source of my problem.

I accidentally called ATTrackingManager.requestTrackingAuthorization twice.
The first time I called while the app was not in an active state. It seems if the first call is made outside active state, any other calls will no longer show the popup.

iOS 14 requestTrackingAuthorization status always denied

The thing that finally worked for me was a "General->Reset->Reset All Content and Settings".

Then when I installed my app the prompt appeared and I could select to Allow tracking. Afterwards my app appeared in Settings, which it had not before, and on tapping it there's an option to disable/enable tracking. The app also now appears in Privacy/Tracking, which it did not before.

I tested further by deleting the app and reinstalling, and again it showed the message to allow tracking.

The only reason I can think ATT does not work as expected is that all apps installed prior to iOS 14.4 / ATT are assumed to be set to "do not allow tracking," but the OS misses adding the app to the Settings page so there's no way of changing it. Although, this does not explain why an uninstall/reinstall of the app still doesn't work.

In conclusion, creating a fresh app might work (untested), but factory reset definitely does work.

Xamarin.iOS: Crash when calling ATTrackingManager.RequestTrackingAuthorization

I don't really understand why, but the problem was with the Info.plist file. Although it had the required key:

<key>NSUserTrackingUsageDescription</key>
<string>Placeholder text...</string>

... seems like this was being ignored. Once I've edited the string in Visual Studio, it all started working again.

Mysterious crash when requesting tracking authorization == Check/update the "NSUserTrackingUsageDescription" string in the Info.plist file.



Related Topics



Leave a reply



Submit