FIRIAMMessageDefinition.h 2.3 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 "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. - (instancetype)init NS_UNAVAILABLE;
  32. /**
  33. * Create a regular message definition.
  34. */
  35. - (instancetype)initWithRenderData:(FIRIAMMessageRenderData *)renderData
  36. startTime:(NSTimeInterval)startTime
  37. endTime:(NSTimeInterval)endTime
  38. triggerDefinition:(NSArray<FIRIAMDisplayTriggerDefinition *> *)renderTriggers;
  39. /**
  40. * Create a test message definition.
  41. */
  42. - (instancetype)initTestMessageWithRenderData:(FIRIAMMessageRenderData *)renderData;
  43. - (BOOL)messageHasExpired;
  44. - (BOOL)messageHasStarted;
  45. // should this message be rendered given the FIAM trigger type? only use this method for app launch
  46. // and foreground trigger, use messageRenderedOnAnalyticsEvent: for analytics triggers
  47. - (BOOL)messageRenderedOnTrigger:(FIRIAMRenderTrigger)trigger;
  48. // should this message be rendered when a given analytics event is fired?
  49. - (BOOL)messageRenderedOnAnalyticsEvent:(NSString *)eventName;
  50. @end
  51. NS_ASSUME_NONNULL_END