1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- //
- // AppDelegate.swift
- // Introduce
- //
- // Created by 胡志强 on 2021/11/29.
- //
- import BFCommonKit
- import BFMaterialKit
- import UIKit
- @main
- class AppDelegate: UIResponder, UIApplicationDelegate {
- var window: UIWindow?
- var isEnterBack: Bool = false // 进入后台
- var notificationUserInfo: [String: Any]?
-
- func application(_: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
- // 初始化配置
- INAppConfigUtil.pageConfig()
- if launchOptions?.keys.contains(UIApplication.LaunchOptionsKey.remoteNotification) ?? false {
- notificationUserInfo = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any]
- if notificationUserInfo != nil && notificationUserInfo?.keys.contains("type") ?? false {
- PQSingletoMemoryUtil.shared.coldLaunchType = .coldLaunchType_pushRecall
- }
- }
- // 配置启动项
- INAppConfigUtil.applicationConfig(launchOptions:launchOptions)
- // BFMaterialConfig.shared.choseType = .single
- return true
- }
- // MARK: 前后台 Lifecycle
- func applicationWillResignActive(_: UIApplication) {}
- func applicationDidEnterBackground(_: UIApplication) {
- // 热启动重新生成SubSesstionId
- isEnterBack = true
- PQSingletoMemoryUtil.shared.createSubSesstionId()
- BFConfig.shared.subSessionId = getUniqueId(desc: "subSessionid")
- }
- func application(_: UIApplication, supportedInterfaceOrientationsFor _: UIWindow?) -> UIInterfaceOrientationMask {
- return UIInterfaceOrientationMask.portrait
- }
-
- func applicationDidBecomeActive(_: UIApplication) {
- BFLog(message: "applicationDidBecomeActive")
- if isEnterBack {
- // 热启动
- PQSingletoMemoryUtil.shared.isColdLaunch = false
- // 热启动上报
- INAppConfigUtil.appLaunchReportUpload(isHotLaunch: true)
- isEnterBack = false
- }
- }
- }
|