FIRInAppMessaging.h 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. NS_SWIFT_NAME(InAppMessaging)
  43. @interface FIRInAppMessaging : NSObject
  44. /** @fn inAppMessaging
  45. @brief Gets the singleton InAppMessaging object constructed from the default Firebase app
  46. settings.
  47. */
  48. + (FIRInAppMessaging *)inAppMessaging NS_SWIFT_NAME(inAppMessaging());
  49. /**
  50. * Unavailable. Use +inAppMessaging instead.
  51. */
  52. - (instancetype)init __attribute__((unavailable("Use +inAppMessaging instead.")));
  53. /**
  54. * A boolean flag that can be used to suppress messaging display at runtime,
  55. * initialized to false at app startup. Once set to true, the in-app messaging SDK will stop
  56. * rendering any new messages until this flag is set back to false.
  57. */
  58. @property(nonatomic) BOOL messageDisplaySuppressed;
  59. /**
  60. * A boolean flag that can be set at runtime to allow or disallow
  61. * collecting user data on app startup. This property is persisted across app
  62. * restarts and has higher priority over the `FirebaseInAppMessagingAutomaticDataCollectionEnabled`
  63. * flag (if present) in your app's `Info.plist` file.
  64. */
  65. @property(nonatomic) BOOL automaticDataCollectionEnabled;
  66. /**
  67. * This is the display component that will be used by InAppMessaging to render messages.
  68. * If it's `nil`, InAppMessaging will only perform other non-rendering flows (fetching messages for
  69. * example). Any custom implementations of `InAppMessagingDisplay` require setting this property in
  70. * order to take effect.
  71. */
  72. @property(nonatomic) id<FIRInAppMessagingDisplay> messageDisplayComponent;
  73. /**
  74. * Directly requests an in-app message with the given trigger to be shown.
  75. */
  76. - (void)triggerEvent:(NSString *)eventName;
  77. /**
  78. * This delegate should be set on the app side to receive message lifecycle events.
  79. */
  80. @property(nonatomic, weak) id<FIRInAppMessagingDisplayDelegate> delegate;
  81. @end
  82. NS_ASSUME_NONNULL_END