123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- //
- // AppDelegate.swift
- // AIEmoji
- //
- // Created by 100Years on 2025/1/15.
- //
- import UIKit
- var kAppNewVerison = ""
- @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.white
- window?.makeKeyAndVisible()
- initPlatform()
- goToLoadVC()
- return true
- }
- func goToLoadVC() {
- let launchVC = TSLaunchVC()
- launchVC.dismissHandler = { [weak self] in
- guard let self = self else { return }
- JudgmentSkipPage()
- }
- window?.rootViewController = launchVC
- }
- func goToTab(){
- window?.rootViewController = TSTabBarController()
- }
-
- func JudgmentSkipPage() {
- //去掉引导页
- // if UserDefaults.standard.string(forKey: "isFirstInstallApp") == nil {
- // window?.rootViewController = TSBootPageVC { [weak self] in
- // guard let self = self else { return }
- // UserDefaults.standard.set("1", forKey: "isFirstInstallApp")
- // UserDefaults.standard.synchronize()
- // goToTab()
- // }
- // }else{
- goToTab()
- // }
- }
-
- func initPlatform() {
- TSColorConfigShared.naviMianTextColor = .white
- checkAppConfig()
- }
- }
- extension AppDelegate {
- func applicationWillTerminate(_ application: UIApplication) {
- // 当应用即将被终止时,这里也可以添加数据保存逻辑,但系统留给的时间很有限
- NotificationCenter.default.post(name: .kApplicationWillTerminate, object: nil)
- }
-
- 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) {
- checkAppConfig()
- }
- }
- extension AppDelegate {
-
- func checkAppConfig(){
- _ = TSNetworkShared.get(urlType: .config) { data,error in
-
- if let result = kNetWorkResultSuccess(data: data) {
- kAppNewVerison = result.safeString(forKey: "version")
- NotificationCenter.default.post(name: .kRefreshSettingView, object: nil)
- }
- }
- }
-
- }
|