if (@available(iOS 14, *)) {
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
NSString * idfa = [ASIdentifierManager.sharedManager advertisingIdentifier].UUIDString;
}
}];
}
NSString * idfa = [ASIdentifierManager.sharedManager advertisingIdentifier].UUIDString;
IDFA 权限适配基本上就这段代码,需要请求权限:
<key>NSUserTrackingUsageDescription</key>
<string>请根据您业务需求进行填写</string>
但是我测试发现了几点:
1. 系统的允许APP请求追踪的总开关默认打开的,你不用请求权限也可以获取到IDFA;
2. 当这个开关关闭时,即使我调用了请求IDFA权限的API,系统也不会弹出弹窗让你点击;
3. 当这个开关打开时,我调用了请求IDFA权限的API,弹窗我点击了不允许的按钮,之后我就获取不到IDFA了(获取到的是0000-0.......000);
So...我干脆就不调用请求IDFA权限的API了,即不做任何改动;
感觉加了请求权限反而不好,如果大家都注重隐私的话,有几个人会点击允许呢?!
期待明天的苹果审核结果。。。^_^
- 补充:苹果审核通过,哦耶!