【问题标题】:ATT popup is not showing iOS 16ATT 弹出窗口未显示 iOS 16
【发布时间】:2022-12-06 22:11:23
【问题描述】:

ATT 弹出窗口未在 iOS 16 中显示

我尝试了很多方法,但都失败了。 (这个项目没有AppDelegate和SceneDelegate所以我没法尝试)

  1. init()
    我还更改了 10 秒的延迟,但没有用。
    @main
    struct lockAppApp: App {
        var body: some Scene {
            WindowGroup {
                ContentView()
            }
        }
        
        init() {
            GADMobileAds.sharedInstance().start(completionHandler: nil)
            
            DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
                if #available(iOS 14, *) {
                    ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
                    })
                }
            }
        }
    }
    
    
    1. View 它只是打印“未确定”
    struct ContentView: View {
        var body: some View {
            ZStack(alignment: .top) {
                GifImage("help")
                    .frame(width: UIScreen.main.bounds.width - (UIScreen.main.bounds.width * 0.3))
            }
            .onReceive(NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)) { _ in
                ATTrackingManager.requestTrackingAuthorization(completionHandler: { status in
                    switch status {
                    case .authorized:
                        print("Authorized")
                    case .denied:
                        print("Denied")
                    case .notDetermined:
                        ATTrackingManager.requestTrackingAuthorization(completionHandler: {_ in})
                        print("Not Determined")
                    case .restricted:
                        print("Restricted")
                    @unknown default:
                        print("Unknown")
                    }
                    
                })
            }
        }
    }
    

【问题讨论】:

    标签: ios swiftui


    【解决方案1】:

    您只能询问一次,并且仅当用户想要被询问时。

    如果用户转到Settings > Privacy & Security > Tracking > Allows Apps to Request to Track,他们可以阻止任何此类请求

    【讨论】:

      猜你喜欢
      • 2018-12-12
      • 1970-01-01
      • 2022-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-14
      • 1970-01-01
      • 2015-08-28
      相关资源
      最近更新 更多