@@ -46,33 +46,17 @@ @interface FIRRemoteConfigSettings () {
4646}
4747@end
4848
49- // Implementations depend upon multiple deprecated APIs
50- #pragma clang diagnostic push
51- #pragma clang diagnostic ignored "-Wdeprecated-declarations"
52-
5349@implementation FIRRemoteConfigSettings
54- - (instancetype )initWithDeveloperModeEnabled : (BOOL )developerModeEnabled {
55- self = [self init ];
56- if (self) {
57- _developerModeEnabled = developerModeEnabled;
58- }
59- return self;
60- }
6150
6251- (instancetype )init {
6352 self = [super init ];
6453 if (self) {
65- _developerModeEnabled = NO ;
6654 _minimumFetchInterval = RCNDefaultMinimumFetchInterval;
6755 _fetchTimeout = RCNHTTPDefaultConnectionTimeout;
6856 }
6957 return self;
7058}
7159
72- - (BOOL )isDeveloperModeEnabled {
73- return _developerModeEnabled;
74- }
75-
7660@end
7761
7862@implementation FIRRemoteConfig {
@@ -241,7 +225,7 @@ - (void)fetchAndActivateWithCompletionHandler:
241225 // Fetch completed. We are being called on the main queue.
242226 // If fetch is successful, try to activate the fetched config
243227 if (fetchStatus == FIRRemoteConfigFetchStatusSuccess && !fetchError) {
244- [strongSelf activateWithCompletionHandler : ^(NSError *_Nullable activateError) {
228+ [strongSelf activateWithCompletion : ^(BOOL changed, NSError *_Nullable activateError) {
245229 if (completionHandler) {
246230 FIRRemoteConfigFetchAndActivateStatus status =
247231 activateError ? FIRRemoteConfigFetchAndActivateStatusSuccessUsingPreFetchedData
@@ -262,31 +246,9 @@ - (void)fetchAndActivateWithCompletionHandler:
262246
263247#pragma mark - apply
264248
265- - (BOOL )activateFetched {
266- // TODO: We block on the async activate to complete. This method is deprecated and needs
267- // to be removed at the next possible breaking change.
268- __block dispatch_semaphore_t semaphore = dispatch_semaphore_create (0 );
269- __block BOOL didActivate = NO ;
270- [self activateWithCompletionHandler: ^(NSError *_Nullable error) {
271- didActivate = error ? false : true ;
272- dispatch_semaphore_signal (semaphore);
273- }];
274- dispatch_semaphore_wait (semaphore, DISPATCH_TIME_FOREVER);
275- return didActivate;
276- }
277-
278249typedef void (^FIRRemoteConfigActivateChangeCompletion)(BOOL changed, NSError *_Nullable error);
279250
280251- (void )activateWithCompletion : (FIRRemoteConfigActivateChangeCompletion)completion {
281- [self activateWithEitherHandler: completion deprecatedHandler: nil ];
282- }
283-
284- - (void )activateWithCompletionHandler : (FIRRemoteConfigActivateCompletion)completionHandler {
285- [self activateWithEitherHandler: nil deprecatedHandler: completionHandler];
286- }
287-
288- - (void )activateWithEitherHandler : (FIRRemoteConfigActivateChangeCompletion)completion
289- deprecatedHandler : (FIRRemoteConfigActivateCompletion)deprecatedHandler {
290252 __weak FIRRemoteConfig *weakSelf = self;
291253 void (^applyBlock)(void ) = ^(void ) {
292254 FIRRemoteConfig *strongSelf = weakSelf;
@@ -298,8 +260,6 @@ - (void)activateWithEitherHandler:(FIRRemoteConfigActivateChangeCompletion)compl
298260 dispatch_async (dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
299261 completion (NO , error);
300262 });
301- } else if (deprecatedHandler) {
302- deprecatedHandler (error);
303263 }
304264 FIRLogError (kFIRLoggerRemoteConfig , @" I-RCN000068" , @" Internal error activating config." );
305265 return ;
@@ -314,16 +274,6 @@ - (void)activateWithEitherHandler:(FIRRemoteConfigActivateChangeCompletion)compl
314274 dispatch_async (dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
315275 completion (NO , nil );
316276 });
317- } else if (deprecatedHandler) {
318- NSError *error = [NSError
319- errorWithDomain: FIRRemoteConfigErrorDomain
320- code: FIRRemoteConfigErrorInternalError
321- userInfo: @{
322- @" ActivationFailureReason" : @" Most recently fetched config already activated"
323- }];
324- dispatch_async (dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
325- deprecatedHandler (error);
326- });
327277 }
328278 return ;
329279 }
@@ -337,10 +287,6 @@ - (void)activateWithEitherHandler:(FIRRemoteConfigActivateChangeCompletion)compl
337287 dispatch_async (dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
338288 completion (YES , nil );
339289 });
340- } else if (deprecatedHandler) {
341- dispatch_async (dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
342- deprecatedHandler (nil );
343- });
344290 }
345291 };
346292 dispatch_async (_queue, applyBlock);
@@ -367,16 +313,11 @@ - (FIRRemoteConfigValue *)objectForKeyedSubscript:(NSString *)key {
367313}
368314
369315- (FIRRemoteConfigValue *)configValueForKey : (NSString *)key {
370- return [self configValueForKey: key namespace: _FIRNamespace];
371- }
372-
373- - (FIRRemoteConfigValue *)configValueForKey : (NSString *)key namespace : (NSString *)aNamespace {
374- if (!key || !aNamespace) {
316+ if (!key) {
375317 return [[FIRRemoteConfigValue alloc ] initWithData: [NSData data ]
376318 source: FIRRemoteConfigSourceStatic];
377319 }
378- NSString *FQNamespace = [self fullyQualifiedNamespace: aNamespace];
379-
320+ NSString *FQNamespace = [self fullyQualifiedNamespace: _FIRNamespace];
380321 __block FIRRemoteConfigValue *value;
381322 dispatch_sync (_queue, ^{
382323 value = self->_configContent .activeConfig [FQNamespace][key];
@@ -400,17 +341,11 @@ - (FIRRemoteConfigValue *)configValueForKey:(NSString *)key namespace:(NSString
400341}
401342
402343- (FIRRemoteConfigValue *)configValueForKey : (NSString *)key source : (FIRRemoteConfigSource)source {
403- return [self configValueForKey: key namespace: _FIRNamespace source: source];
404- }
405-
406- - (FIRRemoteConfigValue *)configValueForKey : (NSString *)key
407- namespace : (NSString *)aNamespace
408- source : (FIRRemoteConfigSource)source {
409- if (!key || !aNamespace) {
344+ if (!key) {
410345 return [[FIRRemoteConfigValue alloc ] initWithData: [NSData data ]
411346 source: FIRRemoteConfigSourceStatic];
412347 }
413- NSString *FQNamespace = [self fullyQualifiedNamespace: aNamespace ];
348+ NSString *FQNamespace = [self fullyQualifiedNamespace: _FIRNamespace ];
414349
415350 __block FIRRemoteConfigValue *value;
416351 dispatch_sync (_queue, ^{
@@ -441,8 +376,6 @@ - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state
441376
442377#pragma mark - Properties
443378
444- #pragma clang diagnostic push
445- #pragma clang diagnostic ignored "-Wunused-property-ivar"
446379// / Last fetch completion time.
447380- (NSDate *)lastFetchTime {
448381 __block NSDate *fetchTime;
@@ -452,7 +385,6 @@ - (NSDate *)lastFetchTime {
452385 });
453386 return fetchTime;
454387}
455- #pragma clang diagnostic pop
456388
457389- (FIRRemoteConfigFetchStatus)lastFetchStatus {
458390 __block FIRRemoteConfigFetchStatus currentStatus;
@@ -463,16 +395,9 @@ - (FIRRemoteConfigFetchStatus)lastFetchStatus {
463395}
464396
465397- (NSArray *)allKeysFromSource : (FIRRemoteConfigSource)source {
466- return [self allKeysFromSource: source namespace: _FIRNamespace];
467- }
468-
469- - (NSArray *)allKeysFromSource : (FIRRemoteConfigSource)source namespace : (NSString *)aNamespace {
470398 __block NSArray *keys = [[NSArray alloc ] init ];
471399 dispatch_sync (_queue, ^{
472- if (!aNamespace) {
473- return ;
474- }
475- NSString *FQNamespace = [self fullyQualifiedNamespace: aNamespace];
400+ NSString *FQNamespace = [self fullyQualifiedNamespace: self ->_FIRNamespace];
476401 switch (source) {
477402 case FIRRemoteConfigSourceDefault:
478403 if (self->_configContent .defaultConfig [FQNamespace]) {
@@ -492,18 +417,9 @@ - (NSArray *)allKeysFromSource:(FIRRemoteConfigSource)source namespace:(NSString
492417}
493418
494419- (nonnull NSSet *)keysWithPrefix : (nullable NSString *)prefix {
495- return [self keysWithPrefix: prefix namespace: _FIRNamespace];
496- }
497-
498- - (nonnull NSSet *)keysWithPrefix : (nullable NSString *)prefix
499- namespace : (nullable NSString *)aNamespace {
500420 __block NSMutableSet *keys = [[NSMutableSet alloc ] init ];
501- __block NSString *namespaceToCheck = aNamespace;
502421 dispatch_sync (_queue, ^{
503- if (!namespaceToCheck.length ) {
504- return ;
505- }
506- NSString *FQNamespace = [self fullyQualifiedNamespace: namespaceToCheck];
422+ NSString *FQNamespace = [self fullyQualifiedNamespace: self ->_FIRNamespace];
507423 if (self->_configContent .activeConfig [FQNamespace]) {
508424 NSArray *allKeys = [self ->_configContent.activeConfig[FQNamespace] allKeys ];
509425 if (!prefix.length ) {
@@ -522,17 +438,8 @@ - (nonnull NSSet *)keysWithPrefix:(nullable NSString *)prefix
522438
523439#pragma mark - Defaults
524440
525- - (void )setDefaults : (NSDictionary <NSString *, NSObject *> *)defaults {
526- [self setDefaults: defaults namespace: _FIRNamespace];
527- }
528-
529- - (void )setDefaults : (NSDictionary <NSString *, NSObject *> *)defaultConfig
530- namespace : (NSString *)aNamespace {
531- if (!aNamespace) {
532- FIRLogWarning (kFIRLoggerRemoteConfig , @" I-RCN000036" , @" The namespace cannot be empty or nil." );
533- return ;
534- }
535- NSString *FQNamespace = [self fullyQualifiedNamespace: aNamespace];
441+ - (void )setDefaults : (NSDictionary <NSString *, NSObject *> *)defaultConfig {
442+ NSString *FQNamespace = [self fullyQualifiedNamespace: _FIRNamespace];
536443 NSDictionary *defaultConfigCopy = [[NSDictionary alloc ] init ];
537444 if (defaultConfig) {
538445 defaultConfigCopy = [defaultConfig copy ];
@@ -548,14 +455,7 @@ - (void)setDefaults:(NSDictionary<NSString *, NSObject *> *)defaultConfig
548455}
549456
550457- (FIRRemoteConfigValue *)defaultValueForKey : (NSString *)key {
551- return [self defaultValueForKey: key namespace: _FIRNamespace];
552- }
553-
554- - (FIRRemoteConfigValue *)defaultValueForKey : (NSString *)key namespace : (NSString *)aNamespace {
555- if (!key || !aNamespace) {
556- return nil ;
557- }
558- NSString *FQNamespace = [self fullyQualifiedNamespace: aNamespace];
458+ NSString *FQNamespace = [self fullyQualifiedNamespace: _FIRNamespace];
559459 __block FIRRemoteConfigValue *value;
560460 dispatch_sync (_queue, ^{
561461 NSDictionary *defaultConfig = self->_configContent .defaultConfig ;
@@ -572,16 +472,6 @@ - (FIRRemoteConfigValue *)defaultValueForKey:(NSString *)key namespace:(NSString
572472}
573473
574474- (void )setDefaultsFromPlistFileName : (nullable NSString *)fileName {
575- return [self setDefaultsFromPlistFileName: fileName namespace: _FIRNamespace];
576- }
577-
578- - (void )setDefaultsFromPlistFileName : (nullable NSString *)fileName
579- namespace : (nullable NSString *)namespace {
580- if (!namespace || namespace.length == 0 ) {
581- FIRLogWarning (kFIRLoggerRemoteConfig , @" I-RCN000036" , @" The namespace cannot be empty or nil." );
582- return ;
583- }
584- NSString *FQNamespace = [self fullyQualifiedNamespace: namespace];
585475 if (!fileName || fileName.length == 0 ) {
586476 FIRLogWarning (kFIRLoggerRemoteConfig , @" I-RCN000037" ,
587477 @" The plist file '%@ ' could not be found by Remote Config." , fileName);
@@ -595,7 +485,7 @@ - (void)setDefaultsFromPlistFileName:(nullable NSString *)fileName
595485 if (plistFile) {
596486 NSDictionary *defaultConfig = [[NSDictionary alloc ] initWithContentsOfFile: plistFile];
597487 if (defaultConfig) {
598- [self setDefaults: defaultConfig namespace: FQNamespace ];
488+ [self setDefaults: defaultConfig];
599489 }
600490 return ;
601491 }
@@ -607,20 +497,17 @@ - (void)setDefaultsFromPlistFileName:(nullable NSString *)fileName
607497#pragma mark - custom variables
608498
609499- (FIRRemoteConfigSettings *)configSettings {
610- __block BOOL developerModeEnabled = NO ;
611500 __block NSTimeInterval minimumFetchInterval = RCNDefaultMinimumFetchInterval;
612501 __block NSTimeInterval fetchTimeout = RCNHTTPDefaultConnectionTimeout;
613502 dispatch_sync (_queue, ^{
614- developerModeEnabled = [self ->_settings.customVariables[kRemoteConfigDeveloperKey ] boolValue ];
615503 minimumFetchInterval = self->_settings .minimumFetchInterval ;
616504 fetchTimeout = self->_settings .fetchTimeout ;
617505 });
618506 FIRLogDebug (kFIRLoggerRemoteConfig , @" I-RCN000066" ,
619- @" Successfully read configSettings. Developer Mode: %@ , Minimum Fetch Interval:%f , "
507+ @" Successfully read configSettings. Minimum Fetch Interval:%f , "
620508 @" Fetch timeout: %f " ,
621- developerModeEnabled ? @" true" : @" false" , minimumFetchInterval, fetchTimeout);
622- FIRRemoteConfigSettings *settings =
623- [[FIRRemoteConfigSettings alloc ] initWithDeveloperModeEnabled: developerModeEnabled];
509+ minimumFetchInterval, fetchTimeout);
510+ FIRRemoteConfigSettings *settings = [[FIRRemoteConfigSettings alloc ] init ];
624511 settings.minimumFetchInterval = minimumFetchInterval;
625512 settings.fetchTimeout = fetchTimeout;
626513 // / The NSURLSession needs to be recreated whenever the fetch timeout may be updated.
@@ -634,23 +521,16 @@ - (void)setConfigSettings:(FIRRemoteConfigSettings *)configSettings {
634521 return ;
635522 }
636523
637- NSDictionary *settingsToSave = @{
638- kRemoteConfigDeveloperKey : @(configSettings.isDeveloperModeEnabled ),
639- };
640- self->_settings .customVariables = settingsToSave;
641524 self->_settings .minimumFetchInterval = configSettings.minimumFetchInterval ;
642525 self->_settings .fetchTimeout = configSettings.fetchTimeout ;
643526 // / The NSURLSession needs to be recreated whenever the fetch timeout may be updated.
644527 [self ->_configFetch recreateNetworkSession ];
645528 FIRLogDebug (kFIRLoggerRemoteConfig , @" I-RCN000067" ,
646- @" Successfully set configSettings. Developer Mode: %@ , Minimum Fetch Interval:%f , "
529+ @" Successfully set configSettings. Minimum Fetch Interval:%f , "
647530 @" Fetch timeout:%f " ,
648- configSettings.isDeveloperModeEnabled ? @" true" : @" false" ,
649531 configSettings.minimumFetchInterval , configSettings.fetchTimeout );
650532 };
651533 dispatch_async (_queue, setConfigSettingsBlock);
652534}
653535
654- #pragma clang diagnostic push // "-Wdeprecated-declarations"
655-
656536@end
0 commit comments