GitLiveApp / firebase-kotlin-sdk

A Kotlin-first SDK for Firebase
https://gitliveapp.github.io/firebase-kotlin-sdk/
Apache License 2.0
996 stars 147 forks source link

iOS RemoteConfig - `fetchAndActivate` doesn't work with `setDefaults`. #427

Open NedelcuRadu opened 8 months ago

NedelcuRadu commented 8 months ago

Doing this in common code of KMP project:

remoteConfig.setDefaultsSafe(*defaults)
remoteConfig.fetchAndActivate()
log.d { remoteConfig.all }

results in the expected behavior on Android (remote values get fetched and updated), while on iOS they don't (even though the logs say the fetch was successful and values were updated).

Keeping only

remoteConfig.fetchAndActivate()
log.d{ remoteConfig.all }

fixes the issue.

Versions: Kotlin: 1.9.10 FirebaseConfig: 1.10.0

The shared code is integrated with CocoaPods setup using pod("FirebaseRemoteConfig", linkOnly = true) that results in

FirebaseRemoteConfig (10.16.0):
    - FirebaseABTesting (~> 10.0)
    - FirebaseCore (~> 10.0)
    - FirebaseInstallations (~> 10.0)
    - GoogleUtilities/Environment (~> 7.8)
    - "GoogleUtilities/NSData+zlib (~> 7.8)"

in Podfile.lock

Logs:

2023-10-30 11:44:57.489729+0200 companion[10413:364098] 10.16.0 - [FirebaseInstallations][I-FIS002000] -[FIRInstallationsIDController createGetInstallationItemPromise], appName: __FIRAPP_DEFAULT
2023-10-30 11:44:57.489862+0200 companion[10413:364098] 10.16.0 - [FirebaseInstallations][I-FIS002001] -[FIRInstallationsIDController installationWithValidAuthTokenForcingRefresh:0], appName: __FIRAPP_DEFAULT
2023-10-30 11:44:57.489932+0200 companion[10413:364098] 10.16.0 - [FirebaseRemoteConfig][I-RCN000022] Success to get iid : fo6jaYdnpEjznkGZHTaURi.
2023-10-30 11:44:57.489960+0200 companion[10413:364098] 10.16.0 - [FirebaseRemoteConfig][I-RCN000060] Fetch with user properties completed.
2023-10-30 11:44:57.489980+0200 companion[10413:364098] 10.16.0 - [FirebaseRemoteConfig][I-RCN000061] Fetch with user properties initiated.
2023-10-30 11:44:57.490152+0200 companion[10413:364098] 10.16.0 - [FirebaseRemoteConfig][I-RCN000040] Start config fetch.
2023-10-30 11:44:57.490177+0200 companion[10413:364098] 10.16.0 - [FirebaseRemoteConfig][I-RCN000061] Making remote config fetch.
2023-10-30 11:44:57.490197+0200 companion[10413:364098] 10.16.0 - [FirebaseRemoteConfig][I-RCN000046] Making config request: https://firebaseremoteconfig.googleapis.com/v1/projects/companion-app-d53f1/namespaces/firebase:fetch?key=...
2023-10-30 11:44:57.849994+0200 companion[10413:364100] 10.16.0 - [FirebaseRemoteConfig][I-RCN000050] config fetch completed. Error: nil StatusCode: 200
2023-10-30 11:44:57.850074+0200 companion[10413:364100] 10.16.0 - [FirebaseRemoteConfig][I-RCN000059] Updating config content from Response for namespace:firebase:__FIRAPP_DEFAULT with state: UPDATE
2023-10-30 11:44:57.850126+0200 companion[10413:364100] 10.16.0 - [FirebaseRemoteConfig][I-RCN000058] Update config in DB for namespace:firebase:__FIRAPP_DEFAULT
2023-10-30 11:44:57.850659+0200 companion[10413:364098] 10.16.0 - [FirebaseRemoteConfig][I-RCN000056] Updating metadata with fetch result.
2023-10-30 11:44:57.851603+0200 companion[10413:364098] 10.16.0 - [FirebaseRemoteConfig][I-RCN000069] Most recently fetched config is already activated.
2023-10-30 11:44:57.851986+0200 companion[10413:364093] D/FeatureConfiguration: Fetched features [(isAccountEnabled, false), (isAppSwitchingEnabled, false), (isCallingEnabled, false), (isScreenSharingEnabled, false), (isTabBarEnabled, false), (isArcControlEnabled, false)]
oleksandr-hulak commented 5 months ago

Any feedback on this issue?