@@ -30,6 +30,23 @@ extern NSString *const _Nonnull FIRNamespaceGoogleMobilePlatform NS_SWIFT_NAME(
3030extern NSString *const _Nonnull FIRRemoteConfigThrottledEndTimeInSecondsKey NS_SWIFT_NAME (
3131 RemoteConfigThrottledEndTimeInSecondsKey);
3232
33+ /* *
34+ * Listener registration returned by `addOnConfigUpdateListener`. Calling its method `remove` stops
35+ * the listener from receiving config updates and unregisters itself.
36+ *
37+ * If remove is called and no other listener registrations remain, the connection to the real-time
38+ * RC backend is closed. Subsequently calling `addOnConfigUpdateListener` will re-open the
39+ * connection.
40+ */
41+ NS_SWIFT_NAME (ConfigUpdateListenerRegistration)
42+ @interface FIRConfigUpdateListenerRegistration : NSObject
43+ /* *
44+ * Removes the listener being tracked by this `ConfigUpdateListenerRegistration`. After the initial
45+ * call, subsequent calls have no effect.
46+ */
47+ - (void )remove;
48+ @end
49+
3350// / Indicates whether updated data was successfully fetched.
3451typedef NS_ENUM (NSInteger , FIRRemoteConfigFetchStatus) {
3552 // / Config has never been fetched.
@@ -65,6 +82,20 @@ typedef NS_ERROR_ENUM(FIRRemoteConfigErrorDomain, FIRRemoteConfigError){
6582 FIRRemoteConfigErrorInternalError = 8003 ,
6683} NS_SWIFT_NAME(RemoteConfigError);
6784
85+ // / Remote Config error domain that handles errors for the real-time service.
86+ extern NSString *const _Nonnull FIRRemoteConfigUpdateErrorDomain NS_SWIFT_NAME (RemoteConfigUpdateErrorDomain);
87+ // / Firebase Remote Config real-time service error.
88+ typedef NS_ERROR_ENUM (FIRRemoteConfigUpdateErrorDomain, FIRRemoteConfigUpdateError){
89+ // / Unable to make a connection to the backend.
90+ FIRRemoteConfigUpdateErrorStreamError = 8001 ,
91+ // / Unable to fetch the latest config.
92+ FIRRemoteConfigUpdateErrorNotFetched = 8002 ,
93+ // / The ConfigUpdate message was unparsable.
94+ FIRRemoteConfigUpdateErrorMessageInvalid = 8003 ,
95+ // / The real-time Remote Config service is unavailable.
96+ FIRRemoteConfigUpdateErrorUnavailable = 8004 ,
97+ } NS_SWIFT_NAME(RemoteConfigUpdateError);
98+
6899// / Enumerated value that indicates the source of Remote Config data. Data can come from
69100// / the Remote Config service, the DefaultConfig that is available when the app is first installed,
70101// / or a static initialized value if data is not available from the service or DefaultConfig.
@@ -139,6 +170,17 @@ NS_SWIFT_NAME(RemoteConfigSettings)
139170@property(nonatomic, assign) NSTimeInterval fetchTimeout;
140171@end
141172
173+ #pragma mark - FIRRemoteConfigUpdate
174+ // / Firebase Remote Config update
175+ NS_SWIFT_NAME (RemoteConfigUpdate)
176+ @interface FIRRemoteConfigUpdate : NSObject
177+
178+ // / Parameter keys whose values have been updated from the currently activated values. Includes
179+ // / keys that are added, deleted, and whose value, value source, or metadata has changed.
180+ @property(nonatomic, readonly, nonnull) NSSet<NSString *> *updatedKeys;
181+
182+ @end
183+
142184#pragma mark - FIRRemoteConfig
143185// / Firebase Remote Config class. The class method `remoteConfig()` can be used
144186// / to fetch, activate and read config results and set default config results on the default
@@ -283,4 +325,34 @@ NS_SWIFT_NAME(RemoteConfig)
283325// / nil if the key doesn't exist in the default config.
284326- (nullable FIRRemoteConfigValue *)defaultValueForKey:(nullable NSString *)key;
285327
328+ #pragma mark - Realtime
329+
330+ // / Completion handler invoked by `addOnConfigUpdateListener` when there is an update to
331+ // / the config from the backend.
332+ // /
333+ // / @param configUpdate Information on which key's values have changed
334+ // / @param error Error message on failure.
335+ typedef void (^FIRRemoteConfigUpdateCompletion)(FIRRemoteConfigUpdate *_Nullable configUpdate,
336+ NSError *_Nullable error)
337+ NS_SWIFT_UNAVAILABLE(" Use Swift's closure syntax instead." );
338+
339+ // / Start listening for real-time config updates from the Remote Config backend and automatically
340+ // / fetch updates when they're available.
341+ // /
342+ // / If a connection to the Remote Config backend is not already open, calling this method will
343+ // / open it. Multiple listeners can be added by calling this method again, but subsequent calls
344+ // / re-use the same connection to the backend.
345+ // /
346+ // / Note: Real-time Remote Config requires the Firebase Remote Config Realtime API. See Get started
347+ // / with Firebase Remote Config at https://firebase.google.com/docs/remote-config/get-started for
348+ // / more information.
349+ // /
350+ // / @param listener The configured listener that is called for every config update.
351+ // / @return Returns a registration representing the listener. The registration contains
352+ // / a remove method, which can be used to stop receiving for updates for this particular
353+ // / registration.
354+ - (FIRConfigUpdateListenerRegistration *_Nonnull)addOnConfigUpdateListener:
355+ (FIRRemoteConfigUpdateCompletion _Nonnull)listener
356+ NS_SWIFT_NAME (addOnConfigUpdateListener(remoteConfigUpdateCompletion:));
357+
286358@end
0 commit comments