3939static NSString *const kRemoteConfigMinimumFetchIntervalKey = @" _rcn_minimum_fetch_interval" ;
4040// / Timeout value for waiting on a fetch response.
4141static NSString *const kRemoteConfigFetchTimeoutKey = @" _rcn_fetch_timeout" ;
42+ // / Notification when config is successfully activated
43+ const NSNotificationName FIRRemoteConfigActivateNotification =
44+ @" FIRRemoteConfigActivateNotification" ;
4245
4346// / Listener for the get methods.
4447typedef void (^FIRRemoteConfigListener)(NSString *_Nonnull, NSDictionary *_Nonnull);
@@ -277,7 +280,7 @@ - (void)fetchAndActivateWithCompletionHandler:
277280 [self fetchWithCompletionHandler: fetchCompletion];
278281}
279282
280- #pragma mark - apply
283+ #pragma mark - activate
281284
282285typedef void (^FIRRemoteConfigActivateChangeCompletion)(BOOL changed, NSError *_Nullable error);
283286
@@ -314,13 +317,16 @@ - (void)activateWithCompletion:(FIRRemoteConfigActivateChangeCompletion)completi
314317 toSource: RCNDBSourceActive
315318 forNamespace: self ->_FIRNamespace];
316319 strongSelf->_settings .lastApplyTimeInterval = [[NSDate date ] timeIntervalSince1970 ];
320+ // New config has been activated at this point
317321 FIRLogDebug (kFIRLoggerRemoteConfig , @" I-RCN000069" , @" Config activated." );
318322 [strongSelf->_configContent activatePersonalization ];
319-
320323 // Update experiments only for 3p namespace
321324 NSString *namespace = [strongSelf->_FIRNamespace
322325 substringToIndex: [strongSelf->_FIRNamespace rangeOfString: @" :" ].location];
323326 if ([namespace isEqualToString: FIRNamespaceGoogleMobilePlatform]) {
327+ dispatch_async (dispatch_get_main_queue (), ^{
328+ [self notifyConfigHasActivated ];
329+ });
324330 [strongSelf->_configExperiment updateExperimentsWithHandler: ^(NSError *_Nullable error) {
325331 if (completion) {
326332 dispatch_async (dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
@@ -339,6 +345,19 @@ - (void)activateWithCompletion:(FIRRemoteConfigActivateChangeCompletion)completi
339345 dispatch_async (_queue, applyBlock);
340346}
341347
348+ - (void )notifyConfigHasActivated {
349+ // Need a valid google app name.
350+ if (!_appName) {
351+ return ;
352+ }
353+ // The Remote Config Swift SDK will be listening for this notification so it can tell SwiftUI to
354+ // update the UI.
355+ NSDictionary *appInfoDict = @{kFIRAppNameKey : _appName};
356+ [[NSNotificationCenter defaultCenter ] postNotificationName: FIRRemoteConfigActivateNotification
357+ object: self
358+ userInfo: appInfoDict];
359+ }
360+
342361#pragma mark - helpers
343362- (NSString *)fullyQualifiedNamespace : (NSString *)namespace {
344363 // If this is already a fully qualified namespace, return.
0 commit comments