| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- //
- // AppDelegate.swift
- // Lanu
- //
- // Created by OneeChan on 2025/11/6.
- //
- import UIKit
- import CocoaLumberjackSwift
- import Firebase
- import GoogleSignIn
- @main
- class AppDelegate: UIResponder, UIApplicationDelegate {
- func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
- // Override point for customization after application launch.
-
- setupLogger()
- setupFirebase()
- LNNetworkMonitor.startMonitoring()
-
- _ = LNProfileManager.shared
- _ = LNIMManager.shared
- _ = LNGameMateManager.shared
- _ = LNPurchaseManager.shared
- _ = RechargeManager.shared
- _ = LNLocationManager.shared
- _ = LNRelationManager.shared
- _ = LNDeeplinkManager.shared
- _ = LNKeyboardManager.shared
-
- LNEventDeliver.notifyAppLaunchFinished()
-
- if let url = launchOptions?[.url] as? URL {
- LNDeeplinkManager.shared.handleDeepLink(url)
- }
-
- return true
- }
- // MARK: UISceneSession Lifecycle
- func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
- // Called when a new scene session is being created.
- // Use this method to select a configuration to create the new scene with.
- return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
- }
- func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
- // Called when the user discards a scene session.
- // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
- // Use this method to release any resources that were specific to the discarded scenes, as they will not return.
- }
- }
- extension AppDelegate {
- private func setupFirebase() {
- #if DEBUG
- let plistName = "GoogleService-Info-Debug"
- #else
- let plistName = "GoogleService-Info-Release"
- #endif
- let plistPath = Bundle.main.path(forResource: plistName, ofType: "plist")!
- let options = FirebaseOptions(contentsOfFile: plistPath)
- FirebaseApp.configure(options: options!)
- }
-
- private func setupLogger() {
- #if DEBUG // 只在 Debug 模式打印到终端
- let logger = DDOSLogger.sharedInstance
- logger.logFormatter = LNLoggerFormater()
- DDLog.add(logger)
- #endif
-
- let fileLogger = DDFileLogger()
- fileLogger.logFormatter = LNLoggerFormater()
- fileLogger.rollingFrequency = 24 * 60 * 60 // 1 天轮转
- fileLogger.logFileManager.maximumNumberOfLogFiles = 7 // 最多保存 7 个文件
- fileLogger.maximumFileSize = 5 * 1024 * 1024 // 5M 最大限制
- DDLog.add(fileLogger)
- }
- }
|