解決方案:
請(qǐng)求權(quán)限的方法的調(diào)用從didFinishLaunchingWithOptions中移動(dòng)到applicationDidBecomeActive這里。
// #import <AppTrackingTransparency/AppTrackingTransparency.h>
- (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) {
// 后續(xù)操作
}
}];
}
}
被拒了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上沒有權(quán)限請(qǐng)求,但info.plist里又有Privacy - Tracking Usage Description配置,我模擬器運(yùn)行一下果然不提示,沒有升iOS15時(shí)之前正常的呀。
國(guó)內(nèi)搜索了一下,CSDN搜索到相關(guān)文章,看全文還有開VIP,真是TM的....
外網(wǎng)搜索到了一條今天發(fā)布的方法就是做延遲,可以正常顯示,我又看了國(guó)外帖子。

WX20210926-183026@2x.png
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.