Skip to content

Commit bf24629

Browse files
paulb777ncooke3
andauthored
[rc-swift] ConfigRealtime (#14299)
Co-authored-by: Nick Cooke <[email protected]>
1 parent 0a268fe commit bf24629

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

@@ -136,7 +135,8 @@ - (instancetype)initWithAppName:(NSString *)appName
136135
configContent:(RCNConfigContent *)configContent
137136
userDefaults:(nullable NSUserDefaults *)userDefaults
138137
analytics:(nullable id<FIRAnalyticsInterop>)analytics
139-
configFetch:(nullable RCNConfigFetch *)configFetch {
138+
configFetch:(nullable RCNConfigFetch *)configFetch
139+
configRealtime:(nullable RCNConfigRealtime *)configRealtime {
140140
self = [super init];
141141
if (self) {
142142
_appName = appName;
@@ -172,11 +172,15 @@ - (instancetype)initWithAppName:(NSString *)appName
172172
namespace:_FIRNamespace
173173
options:options];
174174
}
175-
176-
_configRealtime = [[RCNConfigRealtime alloc] init:_configFetch
177-
settings:_settings
178-
namespace:_FIRNamespace
179-
options:options];
175+
if (configRealtime) {
176+
_configRealtime = configRealtime;
177+
} else {
178+
_configRealtime = [[RCNConfigRealtime alloc] initWithConfigFetch:_configFetch
179+
settings:_settings
180+
namespace:_FIRNamespace
181+
options:options
182+
installations:nil];
183+
}
180184

181185
[_settings loadConfigFromMetadataTable];
182186

@@ -205,7 +209,8 @@ - (instancetype)initWithAppName:(NSString *)appName
205209
configContent:configContent
206210
userDefaults:nil
207211
analytics:analytics
208-
configFetch:nil];
212+
configFetch:nil
213+
configRealtime:nil];
209214
}
210215

211216
// 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.
@@ -340,6 +324,7 @@ typedef void (^FIRRemoteConfigUpdateCompletion)(FIRRemoteConfigUpdate *_Nullable
340324

341325
// TODO: Below here is temporary public for Swift port
342326

327+
@property(nonatomic, readwrite, strong, nonnull) RCNConfigRealtime *configRealtime;
343328
@property(nonatomic, readonly, strong) RCNConfigSettings *settings;
344329

345330
/// Initialize a FIRRemoteConfig instance with all the required parameters directly. This exists so
@@ -358,7 +343,8 @@ typedef void (^FIRRemoteConfigUpdateCompletion)(FIRRemoteConfigUpdate *_Nullable
358343
configContent:(RCNConfigContent *)configContent
359344
userDefaults:(nullable NSUserDefaults *)userDefaults
360345
analytics:(nullable id<FIRAnalyticsInterop>)analytics
361-
configFetch:(nullable RCNConfigFetch *)configFetch;
346+
configFetch:(nullable RCNConfigFetch *)configFetch
347+
configRealtime:(nullable RCNConfigRealtime *)configRealtime;
362348

363349
/// Register `FIRRolloutsStateSubscriber` to `FIRRemoteConfig` instance
364350
- (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)