android - FirebaseRemoteConfig.fetch() does not trigger OnCompleteListener every time -


i'm trying implement firebase remote config :

override fun oncreate(savedinstancestate: bundle?) {      val configsettings = firebaseremoteconfigsettings.builder().setdevelopermodeenabled(buildconfig.debug).build()      mfirebaseremoteconfig = firebaseremoteconfig.getinstance()     mfirebaseremoteconfig.setconfigsettings(configsettings)     mfirebaseremoteconfig.setdefaults(r.xml.remote_config_defaults)     fetchremoteconfig() }  private fun fetchremoteconfig() {     var cacheexpiration = 3600l     if (mfirebaseremoteconfig.info.configsettings.isdevelopermodeenabled) {         cacheexpiration = 0l     }      mfirebaseremoteconfig.fetch(cacheexpiration)         .addoncompletelistener { task ->                 if (task.issuccessful) {                     log.d(tag, "remote config fetch succeeded")                     mfirebaseremoteconfig.activatefetched()                 } else {                     log.d(tag, "remote config fetch failed - ${task.exception?.message}")                 }                  setupview()             } }  private fun setupview() {     val text = mfirebaseremoteconfig.getstring("my_text")     //... } 

my problem oncompletelistener not called. if close/open app several times, setupview() not triggered.

the oncompletelistener should called right? if i'm hitting cache?

edit: if disable developper mode behavior same. callback triggered, not.

i facing same issue , contacted firebase support. replied following:

there bug has been reported oncomplete, onsuccess, , onfailure listeners doesn't called if fetch() called early. [...] there work around can put fetch() inside postresume. can try using in meantime before solution has been released.

i implemented workaround accordingly

protected void onpostresume() {     super.onpostresume();      mfirebaseremoteconfig.fetch(cacheexpiration)             .addonsuccesslistener(new onsuccesslistener<void>() {                 @override                 public void onsuccess(void avoid) {                     log.d(tag, "fetch succeeded");                     // once config fetched must activated before newly fetched values returned.                     mfirebaseremoteconfig.activatefetched();                     // whatever should done on success                 }             })             .addonfailurelistener(new onfailurelistener() {                 @override                 public void onfailure(@nonnull exception exception) {                     log.d(tag, "fetch failed");                     // whatever should done on failure                 }             }); } 

so far seems proposed workaround has resolved issue.

update:

i got notice firebase support. according them issue resolved latest google play services update.

a fix remote config not calling listeners after fetching has been released in newest google play services update. i'll closing case now. if still experiencing issues, feel free reach out , let me know.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -