美文网首页
iOS上架审核之IDFA以及审核被拒问题

iOS上架审核之IDFA以及审核被拒问题

作者: WMSmile | 来源:发表于2022-12-07 10:52 被阅读0次

    iOS上架审核之IDFA以及审核被拒问题

    We're looking forward to completing our review, but we need more information to continue. Your app uses the AppTrackingTransparency framework, but we are still unable to locate the App Tracking Transparency permission request when reviewed on iOS 15.0.

    我们期待着完成我们的审查,但我们需要更多信息来继续。您的应用程序使用AppTrackingTransparency框架,但在iOS 15.0上查看时,我们仍然无法找到app Tracking Transparency权限请求。

    原因:离你使用了AppTrackingTransparency框架,需要弹出权限框

    修改info.plist文件

    添加以下key和value

    <key>NSUserTrackingUsageDescription</key>
    <string>此标识符将用于向您推荐个性化广告。</string>
    

    重要!!!内容尽量完善,例如,我们使用第三方的框架需要追踪使用情况,例如:崩溃统计分析,推送统计分析,我们不追踪用户活动。

    新建一个WMPermissionRequest.swift文件

    //
    //  WMPermissionRequest.swift
    //  
    //
    //  Created by wumeng on 2021/5/13.
    //  Copyright © 2021 wumeng. All rights reserved.
    //
    
    import UIKit
    
    import AppTrackingTransparency
    
    
    class WMPermissionRequest: NSObject {
        
        //NEWLY ADDED PERMISSIONS FOR iOS 14
        static func requestIDFAPermission() {
            if #available(iOS 14, *) {
                #if DEBUG
                print("IDFA status = \(ATTrackingManager.trackingAuthorizationStatus)")
                #endif
                let status = ATTrackingManager.trackingAuthorizationStatus
                switch status {
                case .notDetermined:
                    ATTrackingManager.requestTrackingAuthorization { status in
                        switch status {
                        case .authorized:
                            // Tracking authorization dialog was shown
                            // and we are authorized
                            print("Authorized")
                            // Now that we are authorized we can get the IDFA
                            print(ASIdentifierManager.shared().advertisingIdentifier)
                        case .denied:
                            // Tracking authorization dialog was
                            // shown and permission is denied
                            print("Denied")
                        case .notDetermined:
                            // Tracking authorization dialog has not been shown
                            print("Not Determined")
                        case .restricted:
                            print("Restricted")
                        @unknown default:
                            print("Unknown")
                        }
                    }
                default:
                    print("default")
                }
    
    
            }
        }
        
        /// 定义私有全局变量,解决在iOS 13 定位权限弹框自动消失的问题
        private static let locationAuthManager = CLLocationManager()
        
        /**
         定位权限
         - parameters: action 权限结果闭包(有无权限,是否第一次请求权限)
         */
        static func authLocation(clouser: @escaping ((Bool,Bool)->())) {
            let authStatus = CLLocationManager.authorizationStatus()
            switch authStatus {
            case .notDetermined:
                //由于IOS8中定位的授权机制改变 需要进行手动授权
                WMPermissionRequest.locationAuthManager.requestAlwaysAuthorization()
                WMPermissionRequest.locationAuthManager.requestWhenInUseAuthorization()
                let status = CLLocationManager.authorizationStatus()
                if  status == .authorizedAlways || status == .authorizedWhenInUse {
                    DispatchQueue.main.async {
                        clouser(true && CLLocationManager.locationServicesEnabled(), true)
                    }
                }else{
                    DispatchQueue.main.async {
                        clouser(false, true)
                    }
                }
            case .restricted:
                clouser(false, false)
            case .denied:
                clouser(false, false)
            case .authorizedAlways:
                clouser(true && CLLocationManager.locationServicesEnabled(), false)
            case .authorizedWhenInUse:
                clouser(true && CLLocationManager.locationServicesEnabled(), false)
            @unknown default:
                clouser(false, false)
            }
        }
        
      
    
    }
    
    
    

    在AppDelegate使用

     func applicationDidBecomeActive(_ application: UIApplication) {
            // 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.
            //请求权限 ios 14.5
            WMPermissionRequest.requestIDFAPermission()
        }
    

    上述代码写在didFinishLaunchingWithOptions中。
    但是从iOS15开始,需要转移到applicationDidBecomeActive中。

    在主界面或者第一个展示页面的viewDidAppear调用。

    override func viewDidAppear(_ animated: Bool) {
            super.viewDidAppear(animated)
            
            //请求权限 ios 14.5
            WMPermissionRequest.requestIDFAPermission()
        }
    

    在 App Store Connect 中设置好App隐私的标识符用于追踪目的即可

    相关文章

      网友评论

          本文标题:iOS上架审核之IDFA以及审核被拒问题

          本文链接:https://www.haomeiwen.com/subject/czjnfdtx.html