由于节流,react-native firebase fetch()操作无法成功完成

时间:2018-11-21 04:56:17

标签: reactjs firebase react-native

import firebase from "react-native-firebase";
remoteKey = "testJSON"
 firebase
            .config()
            .fetch(0)
            .then(() => {
                return firebase.config().activateFetched();
            })
            .then(activated => {
                if (!activated) console.log("Fetched data not activated");
                return firebase.config().getKeysByPrefix(remoteKey);
            });

我在我的react本机项目中的App.js内部调用此函数,但是它给出错误“由于节流而无法完成fetch()操作” 可能是什么问题 ?

1 个答案:

答案 0 :(得分:0)

根据firebase文档,这意味着配置获取已被限制 https://firebase.google.com/docs/reference/ios/firebaseremoteconfig/api/reference/Enums/FIRRemoteConfigFetchStatus?hl=vi

The Remote Config library has a client-side throttle to ensure you don’t ping the service too frequently. By setting your fetchDuration to 0, you’ll hit this throttle and your library will stop making calls.

尝试将.fetch(0)更改为.fetch()或使用以下功能激活开发模式

func activateDebugMode() {
    let debugSettings = FIRRemoteConfigSettings(developerModeEnabled: true)
    FIRRemoteConfig.remoteConfig().configSettings = debugSettings!
}

并先调用它。

import firebase from "react-native-firebase";
remoteKey = "testJSON";
firebase
  .config()
  .fetch()
  .then(() => {
    return firebase.config().activateFetched();
  })
  .then(activated => {
    if (!activated) console.log("Fetched data not activated");
    return firebase.config().getKeysByPrefix(remoteKey);
  });