FIRIAMMessageDefinition.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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/Data/FIRIAMMessageRenderData.h"
  18. #import "FirebaseInAppMessaging/Sources/Private/DisplayTrigger/FIRIAMDisplayTriggerDefinition.h"
  19. @class FIRIAMDisplayTriggerDefinition;
  20. @class ABTExperimentPayload;
  21. NS_ASSUME_NONNULL_BEGIN
  22. @interface FIRIAMMessageDefinition : NSObject
  23. @property(nonatomic, nonnull, readonly) FIRIAMMessageRenderData *renderData;
  24. // metadata data that does not affect the rendering content/effect directly
  25. @property(nonatomic, readonly) NSTimeInterval startTime;
  26. @property(nonatomic, readonly) NSTimeInterval endTime;
  27. // a fiam message can have multiple triggers and any of them on its own can cause
  28. // the message to be rendered
  29. @property(nonatomic, readonly) NSArray<FIRIAMDisplayTriggerDefinition *> *renderTriggers;
  30. /// A flag for client-side testing messages
  31. @property(nonatomic, readonly) BOOL isTestMessage;
  32. /// Additional key-value pairs that can be optionally sent along with the FIAM
  33. @property(nonatomic, nullable, readonly) NSDictionary *appData;
  34. @property(nonatomic, nullable, readonly) ABTExperimentPayload *experimentPayload;
  35. - (instancetype)init NS_UNAVAILABLE;
  36. /**
  37. * Create a regular message definition.
  38. */
  39. - (instancetype)initWithRenderData:(FIRIAMMessageRenderData *)renderData
  40. startTime:(NSTimeInterval)startTime
  41. endTime:(NSTimeInterval)endTime
  42. triggerDefinition:(NSArray<FIRIAMDisplayTriggerDefinition *> *)renderTriggers
  43. appData:(nullable NSDictionary *)appData
  44. experimentPayload:(nullable ABTExperimentPayload *)experimentPayload
  45. isTestMessage:(BOOL)isTestMessage NS_DESIGNATED_INITIALIZER;
  46. - (instancetype)initWithRenderData:(FIRIAMMessageRenderData *)renderData
  47. startTime:(NSTimeInterval)startTime
  48. endTime:(NSTimeInterval)endTime
  49. triggerDefinition:(NSArray<FIRIAMDisplayTriggerDefinition *> *)renderTriggers;
  50. /**
  51. * Create a test message definition.
  52. */
  53. - (instancetype)initTestMessageWithRenderData:(FIRIAMMessageRenderData *)renderData
  54. experimentPayload:(nullable ABTExperimentPayload *)experimentPayload;
  55. - (BOOL)messageHasExpired;
  56. - (BOOL)messageHasStarted;
  57. // should this message be rendered given the FIAM trigger type? only use this method for app launch
  58. // and foreground trigger, use messageRenderedOnAnalyticsEvent: for analytics triggers
  59. - (BOOL)messageRenderedOnTrigger:(FIRIAMRenderTrigger)trigger;
  60. // should this message be rendered when a given analytics event is fired?
  61. - (BOOL)messageRenderedOnAnalyticsEvent:(NSString *)eventName;
  62. @end
  63. NS_ASSUME_NONNULL_END