if (@available(iOS 14, *)) {
ATTrackingManagerAuthorizationStatus status = ATTrackingManager.trackingAuthorizationStatus;
switch (status) {
case ATTrackingManagerAuthorizationStatusDenied:
NSLog(@"用户拒绝IDFA");
break;
case ATTrackingManagerAuthorizationStatusAuthorized:
NSLog(@"用户允许IDFA");
break;
case ATTrackingManagerAuthorizationStatusNotDetermined: {
NSLog(@"用户未做选择或未弹窗IDFA");
// 延迟 1 分钟(60 秒)后请求授权
double delayInSeconds = 10.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
NSLog(@"app追踪IDFA权限:%lu",(unsigned long)status);
}];
});
}
break;
default:
break;
}
} else {
// Fallback on earlier versions
if ([ASIdentifierManager.sharedManager isAdvertisingTrackingEnabled]) {
NSLog(@"用户开启了广告追踪IDFA");
}else {
NSLog(@"用户关闭了广告追踪IDFA");
}
}
cocos加入app追踪
最新推荐文章于 2024-08-15 16:26:05 发布