优惠券swift版马甲包

AppDelegate.swift 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //
  2. // AppDelegate.swift
  3. // MvpGoods
  4. //
  5. // Created by 小花 on 2019/3/18.
  6. // Copyright © 2019年 MVP. All rights reserved.
  7. //
  8. import UIKit
  9. import Alamofire
  10. @UIApplicationMain
  11. class AppDelegate: UIResponder, UIApplicationDelegate {
  12. var window: UIWindow?
  13. func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
  14. currentNetReachability()
  15. configUMeng()
  16. let navBar = UINavigationBar.appearance()
  17. navBar.barTintColor = UIColor.gloadRedColor()
  18. navBar.tintColor = UIColor.white
  19. navBar.titleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
  20. navBar.isTranslucent = false
  21. window = UIWindow(frame: UIScreen.main.bounds)
  22. window?.makeKeyAndVisible()
  23. window?.rootViewController = YMTabbarController()
  24. return true
  25. }
  26. func currentNetReachability() {
  27. let manager = NetworkReachabilityManager()
  28. manager?.listener = { status in
  29. var statusStr: String?
  30. switch status {
  31. case .unknown:
  32. statusStr = "未识别的网络"
  33. break
  34. case .notReachable:
  35. statusStr = "不可用的网络(未连接)"
  36. break
  37. case .reachable:
  38. if (manager?.isReachableOnWWAN)! {
  39. statusStr = "2G,3G,4G...的网络"
  40. } else if (manager?.isReachableOnEthernetOrWiFi)! {
  41. statusStr = "wifi的网络";
  42. }
  43. self.regisAliBCSDK()
  44. manager?.stopListening()
  45. break
  46. }
  47. }
  48. manager?.startListening()
  49. }
  50. func regisAliBCSDK(){
  51. AlibcTradeSDK.sharedInstance()?.asyncInit(success: {
  52. }, failure: { (error) in
  53. })
  54. AlibcTradeSDK.sharedInstance()?.setIsForceH5(false)
  55. }
  56. func configUMeng(){
  57. UMAnalyticsConfig.sharedInstance()?.appKey = YMKEY
  58. UMAnalyticsConfig.sharedInstance()?.channelId = "App Store"
  59. let infoDict = Bundle.main.infoDictionary
  60. let version = infoDict?["CFBundleShortVersionString"]
  61. MobClick.setAppVersion((version as! String))
  62. MobClick.start(withConfigure: UMAnalyticsConfig.sharedInstance())
  63. MobClick.setLogEnabled(true)
  64. }
  65. func applicationWillResignActive(_ application: UIApplication) {
  66. // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
  67. // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
  68. }
  69. func applicationDidEnterBackground(_ application: UIApplication) {
  70. // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
  71. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
  72. }
  73. func applicationWillEnterForeground(_ application: UIApplication) {
  74. // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
  75. }
  76. func applicationDidBecomeActive(_ application: UIApplication) {
  77. // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
  78. }
  79. func applicationWillTerminate(_ application: UIApplication) {
  80. // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
  81. }
  82. }