Skip to content

Commit fff6358

Browse files
authored
Merge pull request #492 from firebase/feature/rc_rest_update
[RemoteConfig] Fix iOS SetConfigSettings
2 parents edee562 + 859072f commit fff6358

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

remote_config/integration_test/src/integration_test.cc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@ TEST_F(FirebaseRemoteConfigTest, TestFetch) {
348348
TEST_F(FirebaseRemoteConfigTest, TestFetchInterval) {
349349
ASSERT_NE(rc_, nullptr);
350350
EXPECT_TRUE(WaitForCompletion(
351-
RunWithRetry([](RemoteConfig* rc) { return rc->Fetch(); }, rc_),
352-
"Fetch"));
353-
EXPECT_TRUE(WaitForCompletion(rc_->Activate(), "Activate"));
351+
RunWithRetry([](RemoteConfig* rc) { return rc->FetchAndActivate(); },
352+
rc_),
353+
"FetchAndActivate"));
354354
uint64_t current_fetch_time = rc_->GetInfo().fetch_time;
355355
// Making sure the config settings's fetch interval is 12 hours
356356
EXPECT_TRUE(WaitForCompletion(SetDefaultConfigSettings(rc_),
@@ -360,18 +360,15 @@ TEST_F(FirebaseRemoteConfigTest, TestFetchInterval) {
360360
RunWithRetry([](RemoteConfig* rc) { return rc->Fetch(); }, rc_),
361361
"Fetch"));
362362
EXPECT_EQ(current_fetch_time, rc_->GetInfo().fetch_time);
363-
#if !(TARGET_OS_IPHONE) // iOS failed to set configSettings
364363
// Update fetch interval to 0
365364
EXPECT_TRUE(WaitForCompletion(SetZeroIntervalConfigSettings(rc_),
366365
"SetZeroIntervalConfigSettings"));
367-
LogDebug("Current Fetch Interval: %lld",
368-
rc_->GetConfigSettings().minimum_fetch_interval_in_milliseconds);
366+
EXPECT_EQ(0, rc_->GetConfigSettings().minimum_fetch_interval_in_milliseconds);
369367
// Third fetch, this should operate the real fetch and update the fetch time.
370368
EXPECT_TRUE(WaitForCompletion(
371369
RunWithRetry([](RemoteConfig* rc) { return rc->Fetch(); }, rc_),
372370
"Fetch"));
373371
EXPECT_NE(current_fetch_time, rc_->GetInfo().fetch_time);
374-
#endif
375372
}
376373

377374
} // namespace firebase_testapp_automated

remote_config/src/ios/remote_config_ios.mm

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,16 @@ static int64_t FutureCompleteWithError(NSError *error, ReferenceCountedFutureImp
347347

348348
Future<void> RemoteConfigInternal::SetConfigSettings(ConfigSettings settings) {
349349
const auto handle = future_impl_.SafeAlloc<void>(kRemoteConfigFnSetConfigSettings);
350-
FIRRemoteConfigSettings *config_settings = impl().configSettings;
351-
config_settings.minimumFetchInterval =
350+
FIRRemoteConfigSettings *newConfigSettings = [[FIRRemoteConfigSettings alloc] init];
351+
newConfigSettings.minimumFetchInterval =
352352
static_cast<NSTimeInterval>(settings.minimum_fetch_interval_in_milliseconds /
353353
::firebase::internal::kMillisecondsPerSecond);
354-
config_settings.fetchTimeout = static_cast<NSTimeInterval>(
354+
newConfigSettings.fetchTimeout = static_cast<NSTimeInterval>(
355355
settings.fetch_timeout_in_milliseconds / ::firebase::internal::kMillisecondsPerSecond);
356-
future_impl_.Complete(handle, kFutureStatusSuccess);
356+
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
357+
[impl() setConfigSettings:newConfigSettings];
358+
future_impl_.Complete(handle, kFutureStatusSuccess);
359+
});
357360
return MakeFuture<void>(&future_impl_, handle);
358361
}
359362

0 commit comments

Comments
 (0)