以前审核都很正常,但是这次最近遇见App Store审核被拒,原因是iOS17下IDFA不弹窗
image.png
网上查看了很多攻略,发现都说的不太完善,这边结合自身成功通过的方法再总结下。
1.General => Frameworks,Libraries,and Embedded Content 中添加AppTrackingTransparecy.framework image.png2.applicationDidBecomeActive中添加下述代码
- (void)applicationDidBecomeActive:(UIApplication *)application {
[self requestIDFA];
}
- (void)requestIDFA {
[self getAppIDFADataWithCompletion:^(NSString *idfa) {
}];
}
- (void)getAppIDFADataWithCompletion:(void (^)(NSString *))completion {
__block NSString *idfa = @"";
if (@available(iOS 14, *)) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
ATTrackingManagerAuthorizationStatus status = [ATTrackingManager trackingAuthorizationStatus];
// 用户还没有做出选择时
if (status == ATTrackingManagerAuthorizationStatusNotDetermined) {
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
idfa = [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString];
} else {
NSLog(@"请在设置-隐私-跟踪中允许App请求跟踪");
idfa = @"";
}
if (completion) {
completion(idfa);
}
}];
} else if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
idfa = [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString];
if (completion) {
completion(idfa);
}
} else {
NSLog(@"用户已拒绝授权或在设置中关闭了IDFA");
idfa = @"";
if (completion) {
completion(idfa);
}
}
});
} else {
idfa = [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString];
if (completion) {
completion(idfa);
}
}
}
3.Info中添加下述内容
image.png
上述能解决非多语言下的情况,但多语言环境,还行执行下面设置
4.Info中移除对应3中的Privacy字段,并在对应的多语言InfoPlist中添加NSUserTrackingUsageDescription的字段
通过以上能解决IDFA不弹窗的问题
网友评论