Skip to content

Commit

Permalink
[rc-swift] ConfigRealtime (#14299)
Browse files Browse the repository at this point in the history
Co-authored-by: Nick Cooke <[email protected]>
  • Loading branch information
paulb777 and ncooke3 authored Jan 3, 2025
1 parent 0a268fe commit bf24629
Show file tree
Hide file tree
Showing 20 changed files with 947 additions and 964 deletions.
21 changes: 13 additions & 8 deletions FirebaseRemoteConfig/Sources/FIRRemoteConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#import "FirebaseCore/Extension/FirebaseCoreInternal.h"
#import "FirebaseRemoteConfig/Sources/Private/FIRRemoteConfig_Private.h"
#import "FirebaseRemoteConfig/Sources/RCNConfigConstants.h"
#import "FirebaseRemoteConfig/Sources/RCNConfigRealtime.h"

#import "FirebaseRemoteConfig/FirebaseRemoteConfig-Swift.h"

Expand Down Expand Up @@ -136,7 +135,8 @@ - (instancetype)initWithAppName:(NSString *)appName
configContent:(RCNConfigContent *)configContent
userDefaults:(nullable NSUserDefaults *)userDefaults
analytics:(nullable id<FIRAnalyticsInterop>)analytics
configFetch:(nullable RCNConfigFetch *)configFetch {
configFetch:(nullable RCNConfigFetch *)configFetch
configRealtime:(nullable RCNConfigRealtime *)configRealtime {
self = [super init];
if (self) {
_appName = appName;
Expand Down Expand Up @@ -172,11 +172,15 @@ - (instancetype)initWithAppName:(NSString *)appName
namespace:_FIRNamespace
options:options];
}

_configRealtime = [[RCNConfigRealtime alloc] init:_configFetch
settings:_settings
namespace:_FIRNamespace
options:options];
if (configRealtime) {
_configRealtime = configRealtime;
} else {
_configRealtime = [[RCNConfigRealtime alloc] initWithConfigFetch:_configFetch
settings:_settings
namespace:_FIRNamespace
options:options
installations:nil];
}

[_settings loadConfigFromMetadataTable];

Expand Down Expand Up @@ -205,7 +209,8 @@ - (instancetype)initWithAppName:(NSString *)appName
configContent:configContent
userDefaults:nil
analytics:analytics
configFetch:nil];
configFetch:nil
configRealtime:nil];
}

// Initialize with default config settings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
@class RCNConfigContent;
@class RCNConfigDBManager;
@class RCNConfigFetch;
@class RCNConfigRealtime;
@protocol FIRAnalyticsInterop;

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

@property(nonatomic, readwrite, strong, nonnull) RCNConfigRealtime *configRealtime;

/// Returns the FIRRemoteConfig instance for your namespace and for the default Firebase App.
/// This singleton object contains the complete set of Remote Config parameter values available to
/// the app, including the Active Config and Default Config.. This object also caches values fetched
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
@class RCNConfigSettings;
@class FIRRemoteConfigValue;
@class RCNConfigFetch;
@class RCNConfigRealtime;
@class FIRConfigUpdateListenerRegistration;
@protocol FIRAnalyticsInterop;

@protocol FIRRolloutsStateSubscriber;
Expand All @@ -42,24 +44,6 @@ extern NSString *const _Nonnull FIRNamespaceGoogleMobilePlatform NS_SWIFT_NAME(
extern NSString *const _Nonnull FIRRemoteConfigThrottledEndTimeInSecondsKey NS_SWIFT_NAME(
RemoteConfigThrottledEndTimeInSecondsKey);

/**
* Listener registration returned by `addOnConfigUpdateListener`. Calling its method `remove` stops
* the associated listener from receiving config updates and unregisters itself.
*
* If remove is called and no other listener registrations remain, the connection to the real-time
* RC backend is closed. Subsequently calling `addOnConfigUpdateListener` will re-open the
* connection.
*/
NS_SWIFT_SENDABLE
NS_SWIFT_NAME(ConfigUpdateListenerRegistration)
@interface FIRConfigUpdateListenerRegistration : NSObject
/**
* Removes the listener associated with this `ConfigUpdateListenerRegistration`. After the
* initial call, subsequent calls have no effect.
*/
- (void)remove;
@end

/// Indicates whether updated data was successfully fetched.
typedef NS_ENUM(NSInteger, FIRRemoteConfigFetchStatus) {
/// Config has never been fetched.
Expand Down Expand Up @@ -340,6 +324,7 @@ typedef void (^FIRRemoteConfigUpdateCompletion)(FIRRemoteConfigUpdate *_Nullable

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

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

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

/// Register `FIRRolloutsStateSubscriber` to `FIRRemoteConfig` instance
- (void)addRemoteConfigInteropSubscriber:(id<FIRRolloutsStateSubscriber> _Nonnull)subscriber;
Expand Down
40 changes: 0 additions & 40 deletions FirebaseRemoteConfig/Sources/RCNConfigRealtime.h

This file was deleted.

Loading

0 comments on commit bf24629

Please sign in to comment.