[英]iOS 15: How to display ATT dialog when the app starts in SwiftUI
[英]ATT Dialog don't show
我的应用程序已完成,最近我将其发送给 AppStore 进行审核。 我收到了有关 App Tracking Transparency 的消息。 所以我尝试在我的应用程序中实现以下代码,但对话框弹出窗口不显示。 请帮忙。
import Foundation
import AppTrackingTransparency
import AdSupport
class AppTrackingManager {
static func requestPermission() {
guard #available(iOS 14, *) else { return }
ATTrackingManager.requestTrackingAuthorization { status in
DispatchQueue.main.async {
switch status {
case .authorized:
// Tracking authorization dialog was shown
// and we are authorized
QonversionManager.setAdvId()
print(ASIdentifierManager.shared().advertisingIdentifier)
print("ATT: Authorized")
// Now that we are authorized we can get the I
case .denied:
// Tracking authorization dialog was
// shown and permission is denied
print("ATT: Denied")
case .notDetermined:
// Tracking authorization dialog has not been shown
print("ATT: Not Determined")
case .restricted:
print("ATT: Restricted")
@unknown default:
print("ATT: Unknown")
}
}
}
}
}
所以我创建了 class 用于跟踪,然后我在 AppDelegate 的 didFinishLaunch 方法中调用了这个函数,但没有任何反应。 我也在 Info.plist 中有这个参数
找到的解决方案:将请求 function 移动到初始视图 controller
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.