AppDelegate.swift 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // AppDelegate.swift
  3. // Introduce
  4. //
  5. // Created by 胡志强 on 2021/11/29.
  6. //
  7. import BFCommonKit
  8. import BFMaterialKit
  9. import UIKit
  10. @main
  11. class AppDelegate: UIResponder, UIApplicationDelegate {
  12. var window: UIWindow?
  13. var isEnterBack: Bool = false // 进入后台
  14. var notificationUserInfo: [String: Any]?
  15. func application(_: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
  16. // 初始化配置
  17. INAppConfigUtil.pageConfig()
  18. if launchOptions?.keys.contains(UIApplication.LaunchOptionsKey.remoteNotification) ?? false {
  19. notificationUserInfo = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any]
  20. if notificationUserInfo != nil && notificationUserInfo?.keys.contains("type") ?? false {
  21. PQSingletoMemoryUtil.shared.coldLaunchType = .coldLaunchType_pushRecall
  22. }
  23. }
  24. // 配置启动项
  25. INAppConfigUtil.applicationConfig(launchOptions:launchOptions)
  26. // BFMaterialConfig.shared.choseType = .single
  27. return true
  28. }
  29. // MARK: 前后台 Lifecycle
  30. func applicationWillResignActive(_: UIApplication) {}
  31. func applicationDidEnterBackground(_: UIApplication) {
  32. // 热启动重新生成SubSesstionId
  33. isEnterBack = true
  34. PQSingletoMemoryUtil.shared.createSubSesstionId()
  35. BFConfig.shared.subSessionId = getUniqueId(desc: "subSessionid")
  36. }
  37. func application(_: UIApplication, supportedInterfaceOrientationsFor _: UIWindow?) -> UIInterfaceOrientationMask {
  38. return UIInterfaceOrientationMask.portrait
  39. }
  40. func applicationDidBecomeActive(_: UIApplication) {
  41. BFLog(message: "applicationDidBecomeActive")
  42. if isEnterBack {
  43. // 热启动
  44. PQSingletoMemoryUtil.shared.isColdLaunch = false
  45. // 热启动上报
  46. INAppConfigUtil.appLaunchReportUpload(isHotLaunch: true)
  47. isEnterBack = false
  48. }
  49. }
  50. }