我试图在我的应用程序中实现应用程序跟踪透明度。我试图在第一个ViewControllor上这样做,但它在上传到试飞后崩溃了应用程序。
在这之后,我发现了很多信息,这应该在appDelegate中完成我是这样做的。当然,我已经在Info.plist中设置了NSUserTrackingUsageDescription
我试着用this post来解决它。
在调试器中,我总是看到“未确定”。有没有人能帮忙解决这个问题?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
requestTrackingPermission()
GADMobileAds.sharedInstance().start(completionHandler: nil)
return true
}
该函数
func requestTrackingPermission() {
if #available(iOS 14, *) {
// ATTrackingManager.requestTrackingAuthorization { status in
ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
switch status {
case .authorized:
// Tracking authorization dialog was shown
// and we are authorized
print("Authorized")
// Now that we are authorized we can get the IDFA
print(ASIdentifierManager.shared().advertisingIdentifier)
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")
}
}
)}
}
2条答案
按热度按时间rmbxnbpk1#
我找到了方法。
添加第一个ViewController
在视图中添加didload
zvokhttg2#
算了,我花了很长时间才找到它。但你不需要用延迟来欺骗它。你只需要显示xcode应用程序是活动的。复制并粘贴以下内容: