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

Rad*_*yar 6 firebase reactjs 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);
            });
Run Code Online (Sandbox Code Playgroud)

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

Cri*_*mez 4

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

\n\n
The Remote Config library has a client-side throttle to ensure you don\xe2\x80\x99t ping the service too frequently. By setting your fetchDuration to 0, you\xe2\x80\x99ll hit this throttle and your library will stop making calls.\n
Run Code Online (Sandbox Code Playgroud)\n\n

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

\n\n
func activateDebugMode() {\n    let debugSettings = FIRRemoteConfigSettings(developerModeEnabled: true)\n    FIRRemoteConfig.remoteConfig().configSettings = debugSettings!\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

并在之前调用它。

\n\n
import firebase from "react-native-firebase";\nremoteKey = "testJSON";\nfirebase\n  .config()\n  .fetch()\n  .then(() => {\n    return firebase.config().activateFetched();\n  })\n  .then(activated => {\n    if (!activated) console.log("Fetched data not activated");\n    return firebase.config().getKeysByPrefix(remoteKey);\n  });\n
Run Code Online (Sandbox Code Playgroud)\n