build-ipa/max/template/playbtest/playbtest/PlayB/YL_PlayVC.swift
2025-10-15 10:58:21 +08:00

159 lines
4.7 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// YL_PlayVC.swift
// playbtest
//
// Created by 16 on 2024/11/5.
//
import UIKit
class YL_PlayVC: UIViewController,UITextViewDelegate {
@IBOutlet weak var textSDKView: UITextView!
@IBOutlet weak var bundleIdLab: UILabel!
@IBOutlet weak var deviceIdLab: UILabel!
@IBOutlet weak var idfaLab: UILabel!
@IBOutlet weak var ipLab: UILabel!
@IBOutlet weak var ad1Lab: UILabel!
@IBOutlet weak var ad2Lab: UILabel!
@IBOutlet weak var ad3Lab: UILabel!
private var observation: NSKeyValueObservation?
private var observationis: NSKeyValueObservation?
var openADTimer:Timer?
let kOpenADPerSec: CGFloat = 0.1 //
let kOpenAdCTimeLength: CGFloat = 30 //
static var totalTimeC: CGFloat = 0.0
override func viewDidLoad() {
super.viewDidLoad()
BbbAdManager.shared.loadAd()
let bundleId = Bundle.main.bundleIdentifier ?? ""
bundleIdLab.text = "Name:\(bundleId)"
let deviceId = BbbAdManager.config.adbrush_deviceid ?? ""
deviceIdLab.text = "DeviceID:\(deviceId)"
let locIp = BbbAdManager.config.adbrush_localip ?? ""
let remoteIp = BbbAdManager.config.remouteIP
ipLab.text = "LocIP:\(locIp),RemoteIp:\(remoteIp)"
if #available(iOS 14, *) {
IDFA.shared.checkATT { idfa in
if let idfa = idfa {
print("IDFA: \(idfa)")
BbbAdManager.config.idfa = idfa
self.idfaLab.text = "IDFA:\(idfa)"
} else {
print("无法获取 IDFA")
}
}
} else {
IDFA.shared.getIDFAForOlderVersions { idfa in
if let idfa = idfa {
print("IDFA: \(idfa)")
BbbAdManager.config.idfa = idfa
self.idfaLab.text = "IDFA:\(idfa)"
} else {
print("无法获取 IDFA")
}
}
}
// RunLoop
/*
DispatchQueue.global(qos: .utility).async { [weak self] in
guard self != nil else { return }
YL_NetWorkManager.saveIphonelogs()
}
*/
textSDKView.delegate = self
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
ad1Lab.text = BbbAdManager.config.adids[0]
ad2Lab.text = BbbAdManager.config.adids[1]
ad3Lab.text = BbbAdManager.config.adids[2]
self.navigationController?.navigationBar.isHidden = true
NotificationCenter.default.addObserver(self, selector: #selector(addTextToTextView), name: NSNotification.Name("adinfo"), object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(adStatusChange), name: NSNotification.Name("adStatus"), object: nil)
NotificationCenter.default.post(name: NSNotification.Name("adinfo"), object: nil, userInfo: ["text": "adbrush_base_url\(BbbAdManager.config.adbrush_base_url)adbrush_deviceid:\(String(describing: BbbAdManager.config.adbrush_deviceid))adbrush_localip:\(String(describing: BbbAdManager.config.adbrush_localip))adbrush_local_url:\(BbbAdManager.config.adbrush_local_url)adbrush_ecpm:\(BbbAdManager.config.adbrush_ecpm)"])
}
// 100
func appendExtraLines1() {
let extraLines = String(repeating: "\n", count: 100)
let currentText = textSDKView.text ?? ""
//
if !currentText.hasSuffix(extraLines) {
textSDKView.text = currentText.trimmingCharacters(in: .whitespacesAndNewlines) + extraLines
}
}
@objc func addTextToTextView(notification: Notification) {
if let newText = notification.userInfo?["text"] as? String {
textSDKView.text.append("\(newText)\n\n")
}
}
@objc func adStatusChange(notification: Notification) {
if let newText = notification.userInfo?["text"] as? String, let id = notification.userInfo?["id"] as? String {
var lab = ad1Lab
if id == BbbAdManager.config.adids[1] {
lab = ad2Lab
} else if id == BbbAdManager.config.adids[2] {
lab = ad3Lab
}
lab?.text = "\(id):\(newText)"
}
}
deinit {
NotificationCenter.default.removeObserver(self)
}
}