iOS15 ATTrackingManager请求权限不弹框

解决方案:
请求权限的方法的调用从didFinishLaunchingWithOptions中移动到applicationDidBecomeActive这里。

// #import 

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    if (@available(iOS 14, *)) {
        [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
            NSLog(@"status = %lu",(unsigned long)status);
            if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
                // 后续操作
            }
        }];
    }
}

被拒了2次,原因都是:

Guideline 2.1 - Information Needed
We continue to find that your app uses the AppTrackingTransparency framework, but we are unable to locate the App Tracking Transparency permission request when reviewed on iOS 15.0.

意思是在iOS15上没有权限请求,但info.plist里又有Privacy - Tracking Usage Description配置,我模拟器运行一下果然不提示,没有升iOS15时之前正常的呀。

国内搜索了一下,CSDN搜索到相关文章,看全文还有开VIP,真是TM的....

外网搜索到了一条今天发布的方法就是做延迟,可以正常显示,我又看了国外帖子。


We were facing this same issue. We were calling the ATT request from our first ViewController's viewDidLoad method, and the popup was not being shown on iOS15 (but working perfectly on iOS14).

We've changed to call the request from the AppDelegate's applicationDidBecomeActive method and it worked! The popup is being presented on the first app launch on iOS15.

你可能感兴趣的:(iOS15 ATTrackingManager请求权限不弹框)