当应用程序第一次打开时,我使用 Firebase 远程配置来获取数据。但问题是我无法在应用程序第一次启动时获取数据。onComplete()方法触发但不返回任何值。如果我关闭应用程序并再次运行,它会从远程配置返回值。
试图在onCreate(), onStart(), 中调用 fetch() onResume(),给它第二次延迟,postDelay()但仍然相同,初始 fetch 始终为空。我知道,远程配置具有setDefaults()在获取默认值之前存储默认值的方法,但是在应用程序内设置默认值并不是我想要的。
这是远程配置的工作方式还是我做错了什么?我发现的唯一解决方法是添加fetch()insideonResume()并再次调用 onResume() onCreate()。结果调用 onResume() 两次。第一次是安卓系统,第二次是代码。
有没有其他方法可以在第一次运行时强制远程配置获取数据?
更新
在从它获取新值之前,onComplete()我必须首先调用内部firebaseRemoteConfig.activateFetched();。
我将Firebase Remote Config添加到应用程序,并且对.setMinimumFetchIntervalInSeconds(...)& 的用途感到困惑.setDeveloperModeEnabled(true/false)。这些文档讨论的是开发人员模式,但我不确定他们是否清楚地解释了其实际功能。它必须与之串联使用setMinimumFetchIntervalInSeconds还是可以单独使用,如果单独使用,它会做什么?
Secondly I'm testing my test boolean value in a debug build of the app, with values set to 5 minutes or hours but still I always get my value within 3 seconds. when I set setDeveloperModeEnabled to false or not add the FirebaseRemoteConfigSettings to my instance at all, I still have not observed the famed throttle exception and I get my values immediately. It basically looks like my cache settings …