SceneDelegateBase.m 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // SceneDelegateBase.m
  3. //
  4. #import "SceneDelegateBase.h"
  5. #import "AppDelegateBase.h"
  6. @implementation SceneDelegateBase
  7. - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
  8. // 系统会自动从 Main.storyboard 创建 window 和 rootViewController
  9. // 这里不需要手动创建
  10. // 如果需要手动创建 window(不使用 storyboard):
  11. // UIWindowScene *windowScene = (UIWindowScene *)scene;
  12. // self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
  13. // [self.window makeKeyAndVisible];
  14. }
  15. - (void)sceneDidDisconnect:(UIScene *)scene {
  16. // 场景断开连接时调用
  17. }
  18. - (void)sceneDidBecomeActive:(UIScene *)scene {
  19. // 场景变为活跃状态时调用
  20. AppDelegateBase *appDelegate = (AppDelegateBase *)[UIApplication sharedApplication].delegate;
  21. if(appDelegate.download_task != nil) {
  22. [appDelegate download_offline:true checkdiskspace:false];
  23. }
  24. appDelegate.forgroundDate = [NSDate date];
  25. #ifdef SCANNER_ORDER
  26. [RAUploadManager configureUploadManager:^(RAUPloadManagerConfigure *configure) {
  27. configure.autoRemoveFinish = YES;
  28. }];
  29. if (!RASingleton.sharedInstance.uploadManager) {
  30. RASingleton.sharedInstance.uploadManager = [RAUploadManager sharedManager];
  31. }
  32. #endif
  33. }
  34. - (void)sceneWillResignActive:(UIScene *)scene {
  35. // 场景即将变为非活跃状态时调用
  36. }
  37. - (void)sceneWillEnterForeground:(UIScene *)scene {
  38. // 场景即将进入前台时调用
  39. }
  40. - (void)sceneDidEnterBackground:(UIScene *)scene {
  41. // 场景进入后台时调用
  42. AppDelegateBase *appDelegate = (AppDelegateBase *)[UIApplication sharedApplication].delegate;
  43. [appDelegate download_offline:false checkdiskspace:false];
  44. #if defined(GOOGLE_ANALYTICS)
  45. NSTimeInterval timing = [[NSDate date] timeIntervalSinceDate:appDelegate.forgroundDate];
  46. appDelegate.forgroundDate = nil;
  47. [GoogleAnalyst trackTimingWithCategory:@"foreground" interval:timing name:@"user used time" label:nil];
  48. #endif
  49. }
  50. @end