Skip to content

Commit ba578ec

Browse files
committed
[Config] Port 'RCNConfigFetch'
1 parent c0f1c3c commit ba578ec

16 files changed

+1153
-1088
lines changed

FirebaseRemoteConfig/Sources/FIRRemoteConfig.m

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#import "FirebaseABTesting/Sources/Private/FirebaseABTestingInternal.h"
2020
#import "FirebaseCore/Extension/FirebaseCoreInternal.h"
2121
#import "FirebaseRemoteConfig/Sources/Private/FIRRemoteConfig_Private.h"
22-
#import "FirebaseRemoteConfig/Sources/Private/RCNConfigFetch.h"
2322
#import "FirebaseRemoteConfig/Sources/RCNConfigConstants.h"
2423
#import "FirebaseRemoteConfig/Sources/RCNConfigRealtime.h"
2524

@@ -136,7 +135,8 @@ - (instancetype)initWithAppName:(NSString *)appName
136135
DBManager:(RCNConfigDBManager *)DBManager
137136
configContent:(RCNConfigContent *)configContent
138137
userDefaults:(nullable NSUserDefaults *)userDefaults
139-
analytics:(nullable id<FIRAnalyticsInterop>)analytics {
138+
analytics:(nullable id<FIRAnalyticsInterop>)analytics
139+
configFetch:(nullable RCNConfigFetch *)configFetch {
140140
self = [super init];
141141
if (self) {
142142
_appName = appName;
@@ -160,14 +160,18 @@ - (instancetype)initWithAppName:(NSString *)appName
160160

161161
// Initialize with default config settings.
162162
[self setDefaultConfigSettings];
163-
_configFetch = [[RCNConfigFetch alloc] initWithContent:_configContent
164-
DBManager:_DBManager
165-
settings:_settings
166-
analytics:analytics
167-
experiment:_configExperiment
168-
queue:_queue
169-
namespace:_FIRNamespace
170-
options:options];
163+
if (configFetch) {
164+
_configFetch = configFetch;
165+
} else {
166+
_configFetch = [[RCNConfigFetch alloc] initWithContent:_configContent
167+
DBManager:_DBManager
168+
settings:_settings
169+
analytics:analytics
170+
experiment:_configExperiment
171+
queue:_queue
172+
namespace:_FIRNamespace
173+
options:options];
174+
}
171175

172176
_configRealtime = [[RCNConfigRealtime alloc] init:_configFetch
173177
settings:_settings
@@ -200,7 +204,8 @@ - (instancetype)initWithAppName:(NSString *)appName
200204
DBManager:DBManager
201205
configContent:configContent
202206
userDefaults:nil
203-
analytics:analytics];
207+
analytics:analytics
208+
configFetch:nil];
204209
}
205210

206211
// Initialize with default config settings.
@@ -250,16 +255,18 @@ - (void)callListeners:(NSString *)key config:(NSDictionary *)config {
250255

251256
#pragma mark - fetch
252257

253-
- (void)fetchWithCompletionHandler:(FIRRemoteConfigFetchCompletion)completionHandler {
258+
- (void)fetchWithCompletionHandler:(void (^_Nullable)(FIRRemoteConfigFetchStatus status,
259+
NSError *_Nullable error))completionHandler {
254260
dispatch_async(_queue, ^{
255261
[self fetchWithExpirationDuration:self->_settings.minimumFetchInterval
256262
completionHandler:completionHandler];
257263
});
258264
}
259265

260266
- (void)fetchWithExpirationDuration:(NSTimeInterval)expirationDuration
261-
completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler {
262-
FIRRemoteConfigFetchCompletion completionHandlerCopy = nil;
267+
completionHandler:(void (^_Nullable)(FIRRemoteConfigFetchStatus status,
268+
NSError *_Nullable error))completionHandler {
269+
void (^completionHandlerCopy)(FIRRemoteConfigFetchStatus, NSError *_Nullable) = nil;
263270
if (completionHandler) {
264271
completionHandlerCopy = [completionHandler copy];
265272
}

FirebaseRemoteConfig/Sources/Private/RCNConfigFetch.h

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

FirebaseRemoteConfig/Sources/Public/FirebaseRemoteConfig/FIRRemoteConfig.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@
1616

1717
#import <Foundation/Foundation.h>
1818

19+
// TODO(ncooke3): Remove unneeded forward declarations after Swift migration.
20+
1921
@class FIRApp;
2022
@class FIRRemoteConfigUpdate;
2123
@class RCNConfigDBManager;
2224
@class RCNConfigContent;
2325
@class FIROptions;
2426
@class RCNConfigSettings;
2527
@class FIRRemoteConfigValue;
28+
@class RCNConfigFetch;
2629
@protocol FIRAnalyticsInterop;
2730

2831
@protocol FIRRolloutsStateSubscriber;
@@ -354,7 +357,8 @@ typedef void (^FIRRemoteConfigUpdateCompletion)(FIRRemoteConfigUpdate *_Nullable
354357
DBManager:(RCNConfigDBManager *)DBManager
355358
configContent:(RCNConfigContent *)configContent
356359
userDefaults:(nullable NSUserDefaults *)userDefaults
357-
analytics:(nullable id<FIRAnalyticsInterop>)analytics;
360+
analytics:(nullable id<FIRAnalyticsInterop>)analytics
361+
configFetch:(nullable RCNConfigFetch *)configFetch;
358362

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

0 commit comments

Comments
 (0)