Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Config] Port 'RCNConfigFetch' #14286

Merged
merged 8 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@

// 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 All @@ -179,7 +183,7 @@
if (analytics) {
_listeners = [[NSMutableArray alloc] init];
RCNPersonalization *personalization =
[[RCNPersonalization alloc] initWithAnalytics:analytics];

Check warning on line 186 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 186 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'
[self addListener:^(NSString *key, NSDictionary *config) {
[personalization logArmActiveWithRcParameter:key config:config];
}];
Expand All @@ -200,7 +204,8 @@
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 @@

#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
Loading