diff --git a/lib/index.d.ts b/lib/index.d.ts index 6f7260b0..4a143322 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -25,7 +25,7 @@ declare module 'react-native-firebase' { RNFirebase.auth.Auth, RNFirebase.auth.AuthStatics >; - // config: FirebaseModule; + config: FirebaseModuleAndStatics; crash: FirebaseModuleAndStatics; crashlytics: FirebaseModuleAndStatics; database: FirebaseModuleAndStatics< @@ -81,7 +81,7 @@ declare module 'react-native-firebase' { // admob(): RNFirebase.admob.AdMob; analytics(): RNFirebase.Analytics; auth(): RNFirebase.auth.Auth; - // config(): RNFirebase.config.Config; + config(): RNFirebase.config.Config; crash(): RNFirebase.crash.Crash; crashlytics(): RNFirebase.crashlytics.Crashlytics; database(): RNFirebase.database.Database; @@ -1483,6 +1483,68 @@ declare module 'react-native-firebase' { } } + namespace config { + interface ConfigSnapshot { + source: string; + val(): any; + } + + interface Object { + [key: string]: ConfigSnapshot; + } + + interface Config { + /** Enable Remote Config developer mode to allow for frequent refreshes of the cache. */ + enableDeveloperMode(): void; + + /** + * Sets default values for the app to use when accessing values. + * Any data fetched and activated will override any default values. + * Any values in the defaults but not on Firebase will be untouched. + */ + setDefaults(defaults: object): void; + + /** + * Fetches the remote config data from Firebase, defined in the dashboard. + * If duration is defined (seconds), data will be locally cached for this duration. + * + * The default duration is 43200 seconds (12 hours). + * To force a cache refresh call the method with a duration of 0. + */ + fetch(duration?: number): Promise; + + /** + * Fetches the remote config data from Firebase, defined in the dashboard. + * The default expiration duration is 43200 seconds (12 hours) + */ + activateFetched(): Promise; + + /** + * Gets a config item by key. + * Returns a snapshot containing source (default, remote or static) and val function. + */ + getValue(key: string): Promise; + + /** + * Gets multiple values by key. + * Returns a snapshot object with snapshot keys e.g. snapshots.foo.val(). + */ + getValues(array: Array): Promise>; + + /** + * Returns all keys as an array by a prefix. If no prefix is defined all keys are returned. + */ + getKeysByPrefix(prefix?: string): Promise>; + + /** + * Sets the default values from a resource: + * - Android: Id for the XML resource, which should be in your application's res/xml folder. + * - iOS: The plist file name, with no file name extension. + */ + setDefaultsFromResource(resource: string | number): void; + } + } + namespace crash { interface Crash { /** Logs a message that will appear in a subsequent crash report. */