解决 iOS 15 上 IDFA 权限弹窗(App Tracking Transparency)不显示

在iOS 15正式版发布后,App提交审核后多次遇到次问题,如何解决?

这里记录下解决过程

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 15.0.

Since you indicated in App Store Connect that you collect data in order to track the user, we need to confirm that App Tracking Transparency has been correctly implemented.

在iOS15 断点调试,发现在回调时候 ATTrackingManagerAuthorizationStatus 还是 ATTrackingManagerAuthorizationStatusNotDetermined

最开始尝试多次调用此方法,发现居然可以弹出idfa弹窗了!

  if (@available(iOS 14,*)) {
        [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
  // 
        }];
    }

苹果在Xcode 13 上官方文档已经进行了更新,以下是苹果官方文档说明

Calls to the API only prompt when the application state is: UIApplicationStateActive. Calls to the API through an app extension do not prompt.

The requestTrackingAuthorizationWithCompletionHandler: is the one-time request to authorize or deny access to app-related data that can be used for tracking the user or the device. The system remembers the user’s choice and doesn’t prompt again unless a user uninstalls and then reinstalls the app on the device.

Xcode 13上 文档截图

调用逻辑

- (void)applicationDidBecomeActive:(UIApplication *)application {
   // 申请权限代码 requestAppTrackAuth ;
}

然后经过一段时间发现大部分情况,将权限申请放在 ```applicationDidBecomeActive 调用可以通过审核

其他小概率不通过的,可以尝试下玄学延时方法 或者 进行状态循环检测

你可能感兴趣的:(解决 iOS 15 上 IDFA 权限弹窗(App Tracking Transparency)不显示)