iOS15 ATTrackingManager請(qǐng)求權(quán)限不彈框

解決方案:
請(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.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容