GDTCORLifecycle.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright 2019 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #import <GoogleDataTransport/GDTCORPlatform.h>
  18. @class GDTCOREvent;
  19. NS_ASSUME_NONNULL_BEGIN
  20. /** A protocol defining the lifecycle events objects in the library must respond to immediately. */
  21. @protocol GDTCORLifecycleProtocol <NSObject>
  22. @optional
  23. /** Indicates an imminent app termination in the rare occurrence when -applicationWillTerminate: has
  24. * been called.
  25. *
  26. * @param app The GDTCORApplication instance.
  27. */
  28. - (void)appWillTerminate:(GDTCORApplication *)app;
  29. /** Indicates that the app is moving to background and eventual suspension or the current UIScene is
  30. * deactivating.
  31. *
  32. * @param app The GDTCORApplication instance.
  33. */
  34. - (void)appWillBackground:(GDTCORApplication *)app;
  35. /** Indicates that the app is resuming operation or a UIScene is activating.
  36. *
  37. * @param app The GDTCORApplication instance.
  38. */
  39. - (void)appWillForeground:(GDTCORApplication *)app;
  40. @end
  41. /** This class manages the library's response to app lifecycle events.
  42. *
  43. * When backgrounding, the library doesn't stop processing events, it's just that several background
  44. * tasks will end up being created for every event that's sent, and the stateful objects of the
  45. * library (GDTCORStorage and GDTCORUploadCoordinator singletons) will deserialize themselves from
  46. * and to disk before and after every operation, respectively.
  47. */
  48. @interface GDTCORLifecycle : NSObject <GDTCORApplicationDelegate>
  49. @end
  50. NS_ASSUME_NONNULL_END