[config] Added setDefaultsFromResource method
This commit is contained in:
parent
d8a0ebb084
commit
fe8c486dcb
|
@ -110,6 +110,11 @@ public class RNFirebaseRemoteConfig extends ReactContextBaseJavaModule {
|
|||
FirebaseRemoteConfig.getInstance().setDefaults(convertedMap);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void setDefaultsFromResource(int resourceId) {
|
||||
FirebaseRemoteConfig.getInstance().setDefaults(resourceId);
|
||||
}
|
||||
|
||||
private void fetchInternal(final Promise promise, Boolean withExpiration, long expirationDuration) {
|
||||
FirebaseRemoteConfig.getInstance().fetch(withExpiration ? expirationDuration : 43200) // 12 hours default
|
||||
.addOnCompleteListener(new OnCompleteListener<Void>() {
|
||||
|
|
|
@ -98,10 +98,24 @@ Returns all keys as an array by a prefix. If no prefix is defined all keys are r
|
|||
firebase.config()
|
||||
.getKeysByPrefix()
|
||||
.then((keys) => {
|
||||
|
||||
console.log('Current keys: ', keys);
|
||||
});
|
||||
```
|
||||
|
||||
### setDefaultsFromResource(filename: `String`)
|
||||
|
||||
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
|
||||
|
||||
```js
|
||||
// Anrdoid
|
||||
firebase.config().setDefaultsFromResource(1337);
|
||||
// iOS
|
||||
firebase.config().setDefaultsFromResource('configDefaults');
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
|
|
|
@ -145,7 +145,7 @@ RCT_EXPORT_METHOD(setDefaults:(NSDictionary *)defaults)
|
|||
[self.remoteConfig setDefaults:defaults];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(setDefaultsFromPlistFileName:(NSString *)fileName)
|
||||
RCT_EXPORT_METHOD(setDefaultsFromResource:(NSString *)fileName)
|
||||
{
|
||||
[self.remoteConfig setDefaultsFromPlistFileName:fileName];
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ export default class RemoteConfig extends Base {
|
|||
}
|
||||
|
||||
/**
|
||||
* Enable Remote Config developer mode to allow for frequent refreshes of the cache
|
||||
*/
|
||||
* Enable Remote Config developer mode to allow for frequent refreshes of the cache
|
||||
*/
|
||||
enableDeveloperMode() {
|
||||
if (!this.developerModeEnabled) {
|
||||
this.log.debug('Enabled developer mode');
|
||||
|
@ -137,9 +137,9 @@ export default class RemoteConfig extends Base {
|
|||
|
||||
/**
|
||||
* Sets default configs from plist for default namespace;
|
||||
* @param filename: The plist file name, with no file name extension
|
||||
* @param resource: The plist file name or resource ID
|
||||
*/
|
||||
setDefaultsFromPlistFileName(filename: String) {
|
||||
FirebaseRemoteConfig.setDefaultsFromPlistFileName(filename);
|
||||
setDefaultsFromResource(resource: String | number) {
|
||||
FirebaseRemoteConfig.setDefaultsFromResource(resource);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue