//// //// AV_LaunchLimitesVC.swift //// anniversary_Project //// //// Created by 忆海16 on 2024/7/11. //// // //import UIKit //import SVProgressHUD //import Photos //import Alamofire ////import AppLovinSDK ////import FirebaseAnalytics //import FirebaseRemoteConfig // //class AV_LaunchLimitesVC: AV_RootVC { // let activityView = UIActivityIndicatorView() //// var interstitialAd: MAInterstitialAd! // var retryAttempt = 0.0 // // var adCheckTimer: Timer? // var adCheckStartTime: Date? // var adLoadTime: Int = 0 // // var idad:String? //// var remoteConfig: RemoteConfig! // // var failureCount = 0 // // private var retryTimer: Timer? // private var retryAttempts = 0 // private let maxRetryAttempts = 3 // private let retryInterval: TimeInterval = 3 // override func viewDidLoad() { // super.viewDidLoad() // // // // // activityView.center = CGPoint(x: self.view.center.x + 10, y: self.view.bounds.size.height - 100 ) // // 停止后,隐藏菊花 // activityView.hidesWhenStopped = true // activityView.color = .black; // activityView.style = UIActivityIndicatorView.Style.whiteLarge // // self.view.addSubview(activityView) // self.activityView.startAnimating() // // // } // // override func viewWillAppear(_ animated: Bool) { // super.viewWillAppear(animated) // navigationController?.navigationBar.isHidden = true // // createInterstitialAd() // DispatchQueue.main.asyncAfter(deadline: .now() + 3) { // // 请求跟踪授权 // requestTrackingAuthorization { idfa in // if let idfa = idfa { // print("IDFA: \(idfa)") // StartManager.shared.idfaid = idfa // print("Stored IDFA: \(StartManager.shared.idfaid ?? "N/A")") // } else { // print("IDFA is not available or tracking authorization denied.") // } // } // } // } // // // // // // func fetchIDFAUntilSuccess() { // DispatchQueue.global(qos: .background).async { // var idfaObtained = false // // while !idfaObtained { // let semaphore = DispatchSemaphore(value: 0) // // requestIDFA { idfa in // if let idfa = idfa { // print("Got IDFA: \(idfa)") // // 执行成功获取 IDFA 后的处理方法 // // self.performActionWithIDFA(idfa) // StartManager.shared.idfaid = idfa // self.setPostSHOW() // idfaObtained = true // } else { // print("Failed to get IDFA, retrying...") // DispatchQueue.global(qos: .background).asyncAfter(deadline: .now() + 1.0) { // semaphore.signal() // } // } // } // // semaphore.wait() // } // } // } // //} //extension AV_LaunchLimitesVC: MAAdDelegate //{ // func createInterstitialAd() { // // let randomString = getRandomString() // // if StartManager.shared.adId == nil{ // StartManager.shared.adId = randomString ?? "bee9f7039e56cc7a" // interstitialAd = MAInterstitialAd(adUnitIdentifier: StartManager.shared.adId!) // print("adid-----\(StartManager.shared.adId ?? "gggg")") // }else{ // interstitialAd = MAInterstitialAd(adUnitIdentifier: StartManager.shared.adId!) // print("adid-----\(StartManager.shared.adId ?? "gggg")") // } // // interstitialAd.delegate = self // self.idad = randomString // // // Load the first ad // interstitialAd.load() // } // // // // MARK: MAAdDelegate Protocol // // /// 当广告加载成功时调用的方法 // func didLoad(_ ad: MAAd) { // // 重试尝试次数重置为0 // retryAttempt = 0 // // 记录广告加载成功的相关信息 // // StartManager.shared.shelfNumber = "开屏加载" // StartManager.shared.succeed = true // StartManager.shared.loadTime = self.adLoadTime // StartManager.shared.adPlatform = "MAX" // StartManager.shared.countryCode = ALSdk.shared().configuration.countryCode // StartManager.shared.adId = self.idad // StartManager.shared.platformResponseTime = ad.requestLatency // StartManager.shared.ecpm = Float(ad.revenue) // StartManager.shared.dsp = ad.dspName // StartManager.shared.network = ad.networkName // // self.setPostload() // // } // // /// 当广告加载失败时调用的方法 // func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError) { // // 广告加载失败,建议进行重试 // // 使用指数递增的延迟时间进行重试,最大延迟时间为 64 秒 // retryAttempt += 1 // let delaySec = pow(2.0, min(6.0, retryAttempt)) // DispatchQueue.main.asyncAfter(deadline: .now() + delaySec) { // self.interstitialAd.load() // } // } // // /// 当广告显示时调用的方法 // func didDisplay(_ ad: MAAd) { // // 暂停您的应用的背景音频 // } // // /// 当用户点击广告时调用的方法 // func didClick(_ ad: MAAd) { // // 用户点击广告 // } // // /// 当广告隐藏时调用的方法 // func didHide(_ ad: MAAd) { // // 恢复您的应用的背景音频 // // 广告隐藏后,预加载下一个广告 // interstitialAd.load() // let appDelegate = UIApplication.shared.delegate // appDelegate?.window??.rootViewController = AV_NAVVC(rootViewController: AV_WaterHomeVC()) // } // // // /// 当广告无法显示时调用的方法 // func didFail(toDisplay ad: MAAd, withError error: MAError) { // // 广告无法显示,建议加载下一个广告 // interstitialAd.load() // } // // // // //} //