问题:
最近公司接入三方广告归因SDK,要求使用IDFA
代码:
- info.plist文件添加跟踪权限请求描述文字
<key>NSUserTrackingUsageDescription</key>
<string>此标识符将用于向您推荐个性化广告。</string>
- 导入框架
#import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <AdSupport/ASIdentifierManager.h>
- 获取广告标识
- (void)applicationDidBecomeActive:(UIApplication *)application {
if (@available(iOS 14, *)) {
// iOS14及以上版本需要先请求权限
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
// 获取到权限后,依然使用老方法获取idfa
if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
NSString *idfa = [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString];
NSLog(@"%@",idfa);
} else {
NSLog(@"请在设置-隐私-跟踪中允许App请求跟踪");
}
}];
} else {
// iOS14以下版本依然使用老方法
// 判断在设置-隐私里用户是否打开了广告跟踪
if ([[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]) {
NSString *idfa = [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString];
NSLog(@"%@",idfa);
} else {
NSLog(@"请在设置-隐私-广告中打开广告跟踪功能");
}
}
}
审核被驳回,驳回信息:
Hello,
The issues we previously identified still need your attention.
Guideline 2.1 - Information Needed
We're looking forward to completing our review, but we need more information to continue.
Your app uses the AppTrackingTransparency framework, but we are unable to locate the App Tracking Transparency permission request when reviewed on iOS 17.2.
Next Steps
Please explain where we can find the App Tracking Transparency permission request in your app. The request should appear before any data is collected that could be used to track the user.
If you've implemented App Tracking Transparency but the permission request is not appearing on devices running the latest OS, please review the available documentation and confirm App Tracking Transparency has been correctly implemented.
If your app does not track users, update your app privacy information in App Store Connect to not declare tracking. You must have the Account Holder or Admin role to update app privacy information.
Resources
- Tracking is linking data collected from your app with third-party data for advertising purposes, or sharing the collected data with a data broker. Learn more about tracking.
- See Frequently Asked Questions about the requirements for apps that track users.
- Review developer documentation for App Tracking Transparency.
解决:
iOS14及以上版本请求权限时需要加个延迟,代码如下:
if (@available(iOS 14, *)) {
// iOS14及以上版本需要先请求权限
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
// 获取到权限后,依然使用老方法获取idfa
if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
NSString *idfa = [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString];
NSLog(@"idfa = %@",idfa);
} else {
NSLog(@"请在设置-隐私-跟踪中允许App请求跟踪");
}
}];
});
} else {
// iOS14以下版本依然使用老方法
// 判断在设置-隐私里用户是否打开了广告跟踪
if ([[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]) {
NSString *idfa = [[ASIdentifierManager sharedManager].advertisingIdentifier UUIDString];
NSLog(@"idfa = %@",idfa);
} else {
NSLog(@"请在设置-隐私-广告中打开广告跟踪功能");
}
}