Skip to content

Commit ad91636

Browse files
paulb777ncooke3
andcommitted
[rc-swift] ConfigRealtime (#14299)
Co-authored-by: Nick Cooke <[email protected]>
1 parent 6ec0a19 commit ad91636

20 files changed

+947
-964
lines changed

FirebaseRemoteConfig/Sources/FIRRemoteConfig.m

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#import "FirebaseCore/Extension/FirebaseCoreInternal.h"
2121
#import "FirebaseRemoteConfig/Sources/Private/FIRRemoteConfig_Private.h"
2222
#import "FirebaseRemoteConfig/Sources/RCNConfigConstants.h"
23-
#import "FirebaseRemoteConfig/Sources/RCNConfigRealtime.h"
2423

2524
#import "FirebaseRemoteConfig/FirebaseRemoteConfig-Swift.h"
2625

@@ -145,7 +144,8 @@ - (instancetype)initWithAppName:(NSString *)appName
145144
configContent:(RCNConfigContent *)configContent
146145
userDefaults:(nullable NSUserDefaults *)userDefaults
147146
analytics:(nullable id<FIRAnalyticsInterop>)analytics
148-
configFetch:(nullable RCNConfigFetch *)configFetch {
147+
configFetch:(nullable RCNConfigFetch *)configFetch
148+
configRealtime:(nullable RCNConfigRealtime *)configRealtime {
149149
self = [super init];
150150
if (self) {
151151
_appName = appName;
@@ -181,11 +181,15 @@ - (instancetype)initWithAppName:(NSString *)appName
181181
namespace:_FIRNamespace
182182
options:options];
183183
}
184-
185-
_configRealtime = [[RCNConfigRealtime alloc] init:_configFetch
186-
settings:_settings
187-
namespace:_FIRNamespace
188-
options:options];
184+
if (configRealtime) {
185+
_configRealtime = configRealtime;
186+
} else {
187+
_configRealtime = [[RCNConfigRealtime alloc] initWithConfigFetch:_configFetch
188+
settings:_settings
189+
namespace:_FIRNamespace
190+
options:options
191+
installations:nil];
192+
}
189193

190194
[_settings loadConfigFromMetadataTable];
191195

@@ -214,7 +218,8 @@ - (instancetype)initWithAppName:(NSString *)appName
214218
configContent:configContent
215219
userDefaults:nil
216220
analytics:analytics
217-
configFetch:nil];
221+
configFetch:nil
222+
configRealtime:nil];
218223
}
219224

220225
// Initialize with default config settings.

FirebaseRemoteConfig/Sources/Private/FIRRemoteConfig_Private.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
@class RCNConfigContent;
2121
@class RCNConfigDBManager;
2222
@class RCNConfigFetch;
23-
@class RCNConfigRealtime;
2423
@protocol FIRAnalyticsInterop;
2524

2625
NS_ASSUME_NONNULL_BEGIN
@@ -34,8 +33,6 @@ NS_ASSUME_NONNULL_BEGIN
3433
/// Config settings are custom settings.
3534
@property(nonatomic, readwrite, strong, nonnull) RCNConfigFetch *configFetch;
3635

37-
@property(nonatomic, readwrite, strong, nonnull) RCNConfigRealtime *configRealtime;
38-
3936
/// Returns the FIRRemoteConfig instance for your namespace and for the default Firebase App.
4037
/// This singleton object contains the complete set of Remote Config parameter values available to
4138
/// the app, including the Active Config and Default Config.. This object also caches values fetched

FirebaseRemoteConfig/Sources/Public/FirebaseRemoteConfig/FIRRemoteConfig.h

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
@class RCNConfigSettings;
2727
@class FIRRemoteConfigValue;
2828
@class RCNConfigFetch;
29+
@class RCNConfigRealtime;
30+
@class FIRConfigUpdateListenerRegistration;
2931
@protocol FIRAnalyticsInterop;
3032

3133
@protocol FIRRolloutsStateSubscriber;
@@ -42,24 +44,6 @@ extern NSString *const _Nonnull FIRNamespaceGoogleMobilePlatform NS_SWIFT_NAME(
4244
extern NSString *const _Nonnull FIRRemoteConfigThrottledEndTimeInSecondsKey NS_SWIFT_NAME(
4345
RemoteConfigThrottledEndTimeInSecondsKey);
4446

45-
/**
46-
* Listener registration returned by `addOnConfigUpdateListener`. Calling its method `remove` stops
47-
* the associated listener from receiving config updates and unregisters itself.
48-
*
49-
* If remove is called and no other listener registrations remain, the connection to the real-time
50-
* RC backend is closed. Subsequently calling `addOnConfigUpdateListener` will re-open the
51-
* connection.
52-
*/
53-
NS_SWIFT_SENDABLE
54-
NS_SWIFT_NAME(ConfigUpdateListenerRegistration)
55-
@interface FIRConfigUpdateListenerRegistration : NSObject
56-
/**
57-
* Removes the listener associated with this `ConfigUpdateListenerRegistration`. After the
58-
* initial call, subsequent calls have no effect.
59-
*/
60-
- (void)remove;
61-
@end
62-
6347
/// Indicates whether updated data was successfully fetched.
6448
typedef NS_ENUM(NSInteger, FIRRemoteConfigFetchStatus) {
6549
/// Config has never been fetched.
@@ -418,6 +402,7 @@ typedef void (^FIRRemoteConfigUpdateCompletion)(FIRRemoteConfigUpdate *_Nullable
418402

419403
// TODO: Below here is temporary public for Swift port
420404

405+
@property(nonatomic, readwrite, strong, nonnull) RCNConfigRealtime *configRealtime;
421406
@property(nonatomic, readonly, strong) RCNConfigSettings *settings;
422407

423408
/// Initialize a FIRRemoteConfig instance with all the required parameters directly. This exists so
@@ -436,7 +421,8 @@ typedef void (^FIRRemoteConfigUpdateCompletion)(FIRRemoteConfigUpdate *_Nullable
436421
configContent:(RCNConfigContent *)configContent
437422
userDefaults:(nullable NSUserDefaults *)userDefaults
438423
analytics:(nullable id<FIRAnalyticsInterop>)analytics
439-
configFetch:(nullable RCNConfigFetch *)configFetch;
424+
configFetch:(nullable RCNConfigFetch *)configFetch
425+
configRealtime:(nullable RCNConfigRealtime *)configRealtime;
440426

441427
/// Register `FIRRolloutsStateSubscriber` to `FIRRemoteConfig` instance
442428
- (void)addRemoteConfigInteropSubscriber:(id<FIRRolloutsStateSubscriber> _Nonnull)subscriber;

FirebaseRemoteConfig/Sources/RCNConfigRealtime.h

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)