Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native firebase fetch() operation cannot be completed successfully ,due to throttling

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);
            });

I am calling this inside App.js in my react native project, but it gives the error "fetch() operation cannot be completed ,due to throttling" What could be the issue ?

like image 622
Radhika Padiyar Avatar asked Nov 21 '18 04:11

Radhika Padiyar


1 Answers

According to firebase documentation it means that config fetch was throttled 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.

Try changing .fetch(0) to .fetch() or use the following function to activate development mode

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

and call it before.

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);
  });
like image 185
Cristian Gomez Avatar answered Nov 19 '22 07:11

Cristian Gomez