FIRIAMFetchFlow.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 "FirebaseInAppMessaging/Sources/Private/Flows/FIRIAMActivityLogger.h"
  18. #import "FirebaseInAppMessaging/Sources/Private/Flows/FIRIAMBookKeeper.h"
  19. #import "FirebaseInAppMessaging/Sources/Private/Flows/FIRIAMDisplayExecutor.h"
  20. #import "FirebaseInAppMessaging/Sources/Private/Flows/FIRIAMMessageClientCache.h"
  21. #import "FirebaseInAppMessaging/Sources/Private/Runtime/FIRIAMSDKModeManager.h"
  22. #import "FirebaseInAppMessaging/Sources/Private/Util/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. NS_EXTENSION_UNAVAILABLE("Firebase In App Messaging is not supported for iOS extensions.")
  40. @interface FIRIAMFetchFlow : NSObject
  41. - (instancetype)initWithSetting:(FIRIAMFetchSetting *)setting
  42. messageCache:(FIRIAMMessageClientCache *)cache
  43. messageFetcher:(id<FIRIAMMessageFetcher>)messageFetcher
  44. timeFetcher:(id<FIRIAMTimeFetcher>)timeFetcher
  45. bookKeeper:(id<FIRIAMBookKeeper>)displayBookKeeper
  46. activityLogger:(FIRIAMActivityLogger *)activityLogger
  47. analyticsEventLogger:(id<FIRIAMAnalyticsEventLogger>)analyticsEventLogger
  48. FIRIAMSDKModeManager:(FIRIAMSDKModeManager *)sdkModeManager
  49. displayExecutor:(FIRIAMDisplayExecutor *)displayExecutor;
  50. // Triggers a potential fetch of in-app messaging from the source. It would check and respect the
  51. // the fetchMinIntervalInMinutes defined in setting
  52. - (void)checkAndFetchForInitialAppLaunch:(BOOL)forInitialAppLaunch;
  53. @end
  54. NS_ASSUME_NONNULL_END