iOS15 IDFA權(quán)限位置調(diào)整

IDFA獲取位置,需要從didFinishLaunchingWithOptions獲取位置,遷移到applicationDidBecomeActive

  - (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, *)) {
   ATTrackingManagerAuthorizationStatus status = ATTrackingManager.trackingAuthorizationStatus;
            switch (status) {
                case ATTrackingManagerAuthorizationStatusDenied:
                    //用戶拒絕IDFA
                    break;
                case ATTrackingManagerAuthorizationStatusAuthorized:{
                    //用戶允許IDFA
                    if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
                        NSString *idfaString = [[ASIdentifierManager sharedManager] advertisingIdentifier].UUIDString;
                        NSLog(@"%@",idfaString);
                    }
                }
                    break;
                case ATTrackingManagerAuthorizationStatusNotDetermined: {
                    //用戶未做選擇或未彈窗IDFA
                    //請(qǐng)求彈出用戶授權(quán)框,只會(huì)在程序運(yùn)行是彈框1次,除非卸載app重裝,通地圖、相機(jī)等權(quán)限彈框一樣
                    [ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
                        if (status == ATTrackingManagerAuthorizationStatusAuthorized) {
                          // 你的操作
                        }

                    }];
                }
                    break;
                default:
                    break;
            }
        } else {
            // Fallback on earlier versions
           if ([ASIdentifierManager.sharedManager isAdvertisingTrackingEnabled]) {
               NSLog(@"用戶開啟了廣告追蹤IDFA");
           }else {
              NSLog(@"用戶關(guān)閉了廣告追蹤IDFA");
           }
        }
}}

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.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 undeclare tracking. You must have the Account Holder or Admin role to update app privacy information.

Resources

最后編輯于
?著作權(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)容