FIRInAppMessaging.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. @class FIRApp;
  18. #import "FIRInAppMessagingRendering.h"
  19. NS_ASSUME_NONNULL_BEGIN
  20. /**
  21. * The root object for in-app messaging iOS SDK.
  22. *
  23. * Note: Firebase In-App Messaging depends on using a Firebase Installation ID and token pair to be
  24. * able to retrieve messages defined for the current app instance. By default, the Firebase In-App
  25. * Messaging SDK will obtain the ID and token pair on app/SDK startup. In its default configuration
  26. * the in-app messaging SDK will send some device and client data (linked to the installation ID)
  27. * to the Firebase backend periodically.
  28. *
  29. * The app can tune the default data collection behavior via certain controls. They are listed in
  30. * descending order below. If a higher-priority setting exists, lower level settings are ignored.
  31. *
  32. * 1. Dynamically turning on or off data collection behavior by setting the
  33. * `automaticDataCollectionEnabled` property on the `InAppMessaging` instance to true or false.
  34. * 2. Setting `FirebaseInAppMessagingAutomaticDataCollectionEnabled` to false in the app's plist
  35. * file.
  36. * 3. Disabling data collection via the global Firebase data collection setting.
  37. *
  38. * This class is unavailable on macOS, macOS Catalyst, and watchOS.
  39. **/
  40. NS_EXTENSION_UNAVAILABLE("Firebase In App Messaging is not supported for iOS extensions.")
  41. API_UNAVAILABLE(macos, watchos)
  42. API_AVAILABLE(ios(13.0), tvos(13.0))
  43. NS_SWIFT_NAME(InAppMessaging)
  44. @interface FIRInAppMessaging : NSObject
  45. /** @fn inAppMessaging
  46. @brief Gets the singleton InAppMessaging object constructed from the default Firebase app
  47. settings.
  48. */
  49. + (FIRInAppMessaging *)inAppMessaging NS_SWIFT_NAME(inAppMessaging());
  50. /**
  51. * Unavailable. Use +inAppMessaging instead.
  52. */
  53. - (instancetype)init __attribute__((unavailable("Use +inAppMessaging instead.")));
  54. /**
  55. * A boolean flag that can be used to suppress messaging display at runtime,
  56. * initialized to false at app startup. Once set to true, the in-app messaging SDK will stop
  57. * rendering any new messages until this flag is set back to false.
  58. */
  59. @property(nonatomic) BOOL messageDisplaySuppressed;
  60. /**
  61. * A boolean flag that can be set at runtime to allow or disallow
  62. * collecting user data on app startup. This property is persisted across app
  63. * restarts and has higher priority over the `FirebaseInAppMessagingAutomaticDataCollectionEnabled`
  64. * flag (if present) in your app's `Info.plist` file.
  65. */
  66. @property(nonatomic) BOOL automaticDataCollectionEnabled;
  67. /**
  68. * This is the display component that will be used by InAppMessaging to render messages.
  69. * If it's `nil`, InAppMessaging will only perform other non-rendering flows (fetching messages for
  70. * example). Any custom implementations of `InAppMessagingDisplay` require setting this property in
  71. * order to take effect.
  72. */
  73. @property(nonatomic) id<FIRInAppMessagingDisplay> messageDisplayComponent;
  74. /**
  75. * Directly requests an in-app message with the given trigger to be shown.
  76. */
  77. - (void)triggerEvent:(NSString *)eventName;
  78. /**
  79. * This delegate should be set on the app side to receive message lifecycle events.
  80. */
  81. @property(nonatomic, weak) id<FIRInAppMessagingDisplayDelegate> delegate;
  82. @end
  83. NS_ASSUME_NONNULL_END