FIRIAMMessageDefinition.h 2.8 KB

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