topon_playb/PlayBTopOn/playB/YL_PlayVC.swift
2025-08-06 16:04:31 +08:00

156 lines
5.0 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
import AnyThinkInterstitial
class YL_PlayVC: UIViewController {
@IBOutlet weak var textSDKView: UITextView!
@IBOutlet weak var bundleIdLab: UILabel!
@IBOutlet weak var deviceIdLab: UILabel!
@IBOutlet weak var ipLab: UILabel!
@IBOutlet weak var idfaLab: 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
var firstShow = true
override func viewDidLoad() {
super.viewDidLoad()
BbbAdManager.shared.loadAd(view:self)
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)")
self.idfaLab.text = "IDFA:\(idfa)"
} else {
print("无法获取 IDFA")
}
}
} else {
IDFA.shared.getIDFAForOlderVersions { idfa in
if let idfa = idfa {
print("IDFA: \(idfa)")
self.idfaLab.text = "IDFA:\(idfa)"
} else {
print("无法获取 IDFA")
}
}
}
BbbAdManager.shared.start()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
if (!firstShow) {
return
}
firstShow = false
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)"])
}
@objc func addTextToTextView(notification: Notification) {
if let newText = notification.userInfo?["text"] as? String {
//
DispatchQueue.global().async {
// 线
DispatchQueue.main.async {
// 线UI
self.textSDKView.text.append("\(newText)\n\n")
}
}
}
}
// 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 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
}
DispatchQueue.global().async {
// 线
DispatchQueue.main.async {
// 线UI
lab?.text = "\(id):\(newText)" }
}
}
}
deinit {
NotificationCenter.default.removeObserver(self)
}
}
extension Notification.Name {
static let adStatusChanged = Notification.Name("adStatusChanged")
}