1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- //
- // AppDelegate.swift
- // AIPlayRingtones
- //
- // Created by 100Years on 2025/5/15.
- //
- import UIKit
- @main
- class AppDelegate: UIResponder, UIApplicationDelegate {
-
- var window: UIWindow?
- var backgroundTaskIdentifier: UIBackgroundTaskIdentifier = .invalid
- func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
-
- window = UIWindow(frame: UIScreen.main.bounds)
- window?.backgroundColor = UIColor.black
- window?.makeKeyAndVisible()
- initPlatform()
- goToLoadVC()
- return true
- }
-
- func goToLoadVC() {
- let launchVC = ASLaunchVC()
- launchVC.dismissHandler = { [weak self] in
- guard let self = self else { return }
- JudgmentSkipPage()
- }
- window?.rootViewController = launchVC
- }
-
- func goToTab() {
- window?.rootViewController = CustomTabBarController()
- }
- func JudgmentSkipPage() {
- // if AppDelegate.isFirstInstallApp() {
- // let bootPageVC = TSBootPageVC { [weak self] in
- // guard let self = self else { return }
- // UserDefaults.standard.set("1", forKey: "isFirstInstallApp")
- // UserDefaults.standard.synchronize()
- // goToTab()
- // }
- // let navi = TSBaseNavigationC(rootViewController: bootPageVC)
- // window?.rootViewController = navi
- // } else {
- goToTab()
- // }
- }
- func initPlatform() {
- DispatchQueue.main.async {//先提前调用,启动下数据库.
- debugPrint("ASRMShared.ringDBHistory.istModels.count = \(ASRMShared.ringDBHistory.listModels.count)")
- }
- }
- }
- extension AppDelegate {
- func applicationDidEnterBackground(_ application: UIApplication) {
- beginBackgroundTask()
- }
- func beginBackgroundTask() {
- backgroundTaskIdentifier = UIApplication.shared.beginBackgroundTask { [weak self] in
- self?.endBackgroundTask()
- }
- }
- func endBackgroundTask() {
- if backgroundTaskIdentifier != .invalid {
- UIApplication.shared.endBackgroundTask(backgroundTaskIdentifier)
- backgroundTaskIdentifier = .invalid
- }
- }
- func applicationWillEnterForeground(_ application: UIApplication) {
- }
-
- func applicationWillTerminate(_ application: UIApplication) {
- // 当应用即将被终止时,这里也可以添加数据保存逻辑,但系统留给的时间很有限
- }
- }
- extension AppDelegate {
-
- static func isFirstInstallApp() -> Bool {
- return UserDefaults.standard.string(forKey: "isFirstInstallApp") == nil
- }
- }
|