Skip to content

Commit

Permalink
[Config] Port 'RCNConfigFetch'
Browse files Browse the repository at this point in the history
  • Loading branch information
ncooke3 committed Dec 26, 2024
1 parent c0f1c3c commit ba578ec
Show file tree
Hide file tree
Showing 16 changed files with 1,153 additions and 1,088 deletions.
35 changes: 21 additions & 14 deletions FirebaseRemoteConfig/Sources/FIRRemoteConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#import "FirebaseABTesting/Sources/Private/FirebaseABTestingInternal.h"
#import "FirebaseCore/Extension/FirebaseCoreInternal.h"
#import "FirebaseRemoteConfig/Sources/Private/FIRRemoteConfig_Private.h"
#import "FirebaseRemoteConfig/Sources/Private/RCNConfigFetch.h"
#import "FirebaseRemoteConfig/Sources/RCNConfigConstants.h"
#import "FirebaseRemoteConfig/Sources/RCNConfigRealtime.h"

Expand Down Expand Up @@ -136,7 +135,8 @@ - (instancetype)initWithAppName:(NSString *)appName
DBManager:(RCNConfigDBManager *)DBManager
configContent:(RCNConfigContent *)configContent
userDefaults:(nullable NSUserDefaults *)userDefaults
analytics:(nullable id<FIRAnalyticsInterop>)analytics {
analytics:(nullable id<FIRAnalyticsInterop>)analytics
configFetch:(nullable RCNConfigFetch *)configFetch {
self = [super init];
if (self) {
_appName = appName;
Expand All @@ -160,14 +160,18 @@ - (instancetype)initWithAppName:(NSString *)appName

// Initialize with default config settings.
[self setDefaultConfigSettings];
_configFetch = [[RCNConfigFetch alloc] initWithContent:_configContent
DBManager:_DBManager
settings:_settings
analytics:analytics
experiment:_configExperiment
queue:_queue
namespace:_FIRNamespace
options:options];
if (configFetch) {
_configFetch = configFetch;
} else {
_configFetch = [[RCNConfigFetch alloc] initWithContent:_configContent
DBManager:_DBManager
settings:_settings
analytics:analytics

Check warning on line 169 in FirebaseRemoteConfig/Sources/FIRRemoteConfig.m

View workflow job for this annotation

GitHub Actions / remoteconfig (iOS)

sending 'id<FIRAnalyticsInterop> _Nullable __strong' to parameter of incompatible type 'id<AnalyticsInterop> _Nullable'

Check warning on line 169 in FirebaseRemoteConfig/Sources/FIRRemoteConfig.m

View workflow job for this annotation

GitHub Actions / sample-build-test

sending 'id<FIRAnalyticsInterop> _Nullable __strong' to parameter of incompatible type 'id<AnalyticsInterop> _Nullable'
experiment:_configExperiment
queue:_queue
namespace:_FIRNamespace
options:options];
}

_configRealtime = [[RCNConfigRealtime alloc] init:_configFetch
settings:_settings
Expand Down Expand Up @@ -200,7 +204,8 @@ - (instancetype)initWithAppName:(NSString *)appName
DBManager:DBManager
configContent:configContent
userDefaults:nil
analytics:analytics];
analytics:analytics
configFetch:nil];
}

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

#pragma mark - fetch

- (void)fetchWithCompletionHandler:(FIRRemoteConfigFetchCompletion)completionHandler {
- (void)fetchWithCompletionHandler:(void (^_Nullable)(FIRRemoteConfigFetchStatus status,
NSError *_Nullable error))completionHandler {
dispatch_async(_queue, ^{
[self fetchWithExpirationDuration:self->_settings.minimumFetchInterval
completionHandler:completionHandler];
});
}

- (void)fetchWithExpirationDuration:(NSTimeInterval)expirationDuration
completionHandler:(FIRRemoteConfigFetchCompletion)completionHandler {
FIRRemoteConfigFetchCompletion completionHandlerCopy = nil;
completionHandler:(void (^_Nullable)(FIRRemoteConfigFetchStatus status,
NSError *_Nullable error))completionHandler {
void (^completionHandlerCopy)(FIRRemoteConfigFetchStatus, NSError *_Nullable) = nil;
if (completionHandler) {
completionHandlerCopy = [completionHandler copy];
}
Expand Down
71 changes: 0 additions & 71 deletions FirebaseRemoteConfig/Sources/Private/RCNConfigFetch.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@

#import <Foundation/Foundation.h>

// TODO(ncooke3): Remove unneeded forward declarations after Swift migration.

@class FIRApp;
@class FIRRemoteConfigUpdate;
@class RCNConfigDBManager;
@class RCNConfigContent;
@class FIROptions;
@class RCNConfigSettings;
@class FIRRemoteConfigValue;
@class RCNConfigFetch;
@protocol FIRAnalyticsInterop;

@protocol FIRRolloutsStateSubscriber;
Expand Down Expand Up @@ -354,7 +357,8 @@ typedef void (^FIRRemoteConfigUpdateCompletion)(FIRRemoteConfigUpdate *_Nullable
DBManager:(RCNConfigDBManager *)DBManager
configContent:(RCNConfigContent *)configContent
userDefaults:(nullable NSUserDefaults *)userDefaults
analytics:(nullable id<FIRAnalyticsInterop>)analytics;
analytics:(nullable id<FIRAnalyticsInterop>)analytics
configFetch:(nullable RCNConfigFetch *)configFetch;

/// Register `FIRRolloutsStateSubscriber` to `FIRRemoteConfig` instance
- (void)addRemoteConfigInteropSubscriber:(id<FIRRolloutsStateSubscriber> _Nonnull)subscriber;
Expand Down
Loading

0 comments on commit ba578ec

Please sign in to comment.