FIRIAMFetchFlow.h 2.4 KB

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