我正在研究在 iOS 14 上获取 IDFA。我使用的是 iPhone 8 Plus。
我已经添加了
<key>NSUserTrackingUsageDescription</key>
<string>App would like to access IDFA for tracking purpose</string>
Run Code Online (Sandbox Code Playgroud)
在.plist文件中。
然后添加
let type = ATTrackingManager.trackingAuthorizationStatus;
Run Code Online (Sandbox Code Playgroud)
返回.denied, 有
func requestPermission() {
ATTrackingManager.requestTrackingAuthorization { 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")
}
}
}
Run Code Online (Sandbox Code Playgroud)
但我.denied没有任何弹出窗口。
你知道发生了什么吗?
dla*_*kty 30
在系统的设置应用程序中有一个选项“允许应用程序请求跟踪”,如果它关闭,requestTrackingAuthorization将.denied立即返回。
Ser*_*myk 17
在 iOS 15 中,仅当应用程序状态已处于活动状态时,才可以使用 ATTrackingManager.requestTrackingAuthorization 进行请求,因此应从 didFinishLaunchingWithOptions 移至 applicationDidBecomeActive
如果全局设置“允许应用程序请求跟踪”处于关闭状态,requestTrackingAuthorization将立即返回.denied。
但对于某些用户来说,即使打开“允许应用程序请求跟踪”,requestTrackingAuthorization也会返回.denied。
这是操作系统问题,已在 14.5.1 版本中修复,因此只需更新操作系统即可获取 ATT 对话框。
iOS 和 iPadOS 14.5.1 发行说明
此更新修复了应用程序跟踪透明度的问题,之前在“设置”中禁用“允许应用程序请求跟踪”的某些用户在重新启用后可能不会收到来自应用程序的提示。此更新还提供重要的安全更新,建议所有用户使用。
| 归档时间: |
|
| 查看次数: |
9827 次 |
| 最近记录: |