AppDelegate.swift 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // AppDelegate.swift
  3. // RainbowPlanet
  4. //
  5. // Created by 南鑫林 on 2019/3/8.
  6. // Copyright © 2019 南鑫林. All rights reserved.
  7. //
  8. import UIKit
  9. @UIApplicationMain
  10. class AppDelegate: UIResponder, UIApplicationDelegate {
  11. var window: UIWindow?
  12. func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
  13. //初始化窗口
  14. initWindow()
  15. DispatchQueue.global(qos: .default).async {
  16. //初始化百度地图
  17. BaiduMapManager.shared.initBaiduMap()
  18. //初始化键盘
  19. DispatchQueue.main.async {
  20. //初始化友盟
  21. UMManager.shared.initUM(launchOptions: launchOptions)
  22. IQKeyboardManagerSwiftManager.shared().initIQKeyboardManagerSwift()
  23. }
  24. }
  25. return true
  26. }
  27. ///当App将从后台回到前台时调用,之后肯定调用applicationDidBecomeActive方法表示程序进入active状态,但App第一次启动时不是从后台启动,所以首次加载时不会调用此方法.
  28. func applicationWillEnterForeground(_ application: UIApplication) {
  29. SwiftMoyaNetWorkServiceUser.shared().userMemberMessageIndexApi {
  30. (messageIndexModel) -> (Void) in
  31. let messageIndexModel = messageIndexModel as? MessageIndexModel
  32. if messageIndexModel?.activity?.isYes == 1 || messageIndexModel?.follow?.isYes == 1 || messageIndexModel?.notification?.isYes == 1 || messageIndexModel?.praise?.isYes == 1 || messageIndexModel?.comment?.isYes == 1 {
  33. NotificationCenter.default.post(name: NSNotification.Name(rawValue: "MessageMainViewController"), object: messageIndexModel)
  34. }
  35. }
  36. }
  37. }