FIRIAMFetchFlow.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright 2017 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 "FIRIAMActivityLogger.h"
  18. #import "FIRIAMBookKeeper.h"
  19. #import "FIRIAMDisplayExecutor.h"
  20. #import "FIRIAMMessageClientCache.h"
  21. #import "FIRIAMSDKModeManager.h"
  22. #import "FIRIAMTimeFetcher.h"
  23. @protocol FIRIAMAnalyticsEventLogger;
  24. NS_ASSUME_NONNULL_BEGIN
  25. @interface FIRIAMFetchSetting : NSObject
  26. @property(nonatomic) NSTimeInterval fetchMinIntervalInMinutes;
  27. @end
  28. typedef void (^FIRIAMFetchMessageCompletionHandler)(
  29. NSArray<FIRIAMMessageDefinition *> *_Nullable messages,
  30. NSNumber *_Nullable nextFetchWaitTime,
  31. NSInteger discardedMessageCount,
  32. NSError *_Nullable error);
  33. @protocol FIRIAMMessageFetcher
  34. - (void)fetchMessagesWithImpressionList:(NSArray<FIRIAMImpressionRecord *> *)impressonList
  35. withCompletion:(FIRIAMFetchMessageCompletionHandler)completion;
  36. @end
  37. // Parent class for supporting different fetching flows. Subclass is supposed to trigger
  38. // checkAndFetch at appropriate moments based on its fetch strategy
  39. @interface FIRIAMFetchFlow : NSObject
  40. - (instancetype)initWithSetting:(FIRIAMFetchSetting *)setting
  41. messageCache:(FIRIAMMessageClientCache *)cache
  42. messageFetcher:(id<FIRIAMMessageFetcher>)messageFetcher
  43. timeFetcher:(id<FIRIAMTimeFetcher>)timeFetcher
  44. bookKeeper:(id<FIRIAMBookKeeper>)displayBookKeeper
  45. activityLogger:(FIRIAMActivityLogger *)activityLogger
  46. analyticsEventLogger:(id<FIRIAMAnalyticsEventLogger>)analyticsEventLogger
  47. FIRIAMSDKModeManager:(FIRIAMSDKModeManager *)sdkModeManager
  48. displayExecutor:(FIRIAMDisplayExecutor *)displayExecutor;
  49. // Triggers a potential fetch of in-app messaging from the source. It would check and respect the
  50. // the fetchMinIntervalInMinutes defined in setting
  51. - (void)checkAndFetchForInitialAppLaunch:(BOOL)forInitialAppLaunch;
  52. @end
  53. NS_ASSUME_NONNULL_END