@react-native-firebase/remote-config 24.1.1 → 25.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/android/src/reactnative/java/io/invertase/firebase/config/ReactNativeFirebaseConfigModule.java +11 -5
- package/dist/module/RemoteConfigValue.js +53 -0
- package/dist/module/RemoteConfigValue.js.map +1 -0
- package/dist/module/index.js +27 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/modular.js +155 -0
- package/dist/module/modular.js.map +1 -0
- package/dist/module/namespaced.js +400 -0
- package/dist/module/namespaced.js.map +1 -0
- package/dist/module/package.json +1 -0
- package/{lib → dist/module}/polyfills.js +26 -11
- package/dist/module/polyfills.js.map +1 -0
- package/dist/module/polyfills.web.js +3 -0
- package/dist/module/polyfills.web.js.map +1 -0
- package/{lib → dist/module}/statics.js +5 -3
- package/dist/module/statics.js.map +1 -0
- package/dist/module/types/internal.js +4 -0
- package/dist/module/types/internal.js.map +1 -0
- package/dist/module/types/namespaced.js +24 -0
- package/dist/module/types/namespaced.js.map +1 -0
- package/dist/module/types/remote-config.js +4 -0
- package/dist/module/types/remote-config.js.map +1 -0
- package/dist/module/version.js +5 -0
- package/dist/module/version.js.map +1 -0
- package/dist/module/web/RNFBConfigModule.android.js +6 -0
- package/dist/module/web/RNFBConfigModule.android.js.map +1 -0
- package/dist/module/web/RNFBConfigModule.ios.js +6 -0
- package/dist/module/web/RNFBConfigModule.ios.js.map +1 -0
- package/{lib → dist/module}/web/RNFBConfigModule.js +69 -77
- package/dist/module/web/RNFBConfigModule.js.map +1 -0
- package/dist/typescript/lib/RemoteConfigValue.d.ts +16 -0
- package/dist/typescript/lib/RemoteConfigValue.d.ts.map +1 -0
- package/dist/typescript/lib/index.d.ts +6 -0
- package/dist/typescript/lib/index.d.ts.map +1 -0
- package/dist/typescript/lib/modular.d.ts +76 -0
- package/dist/typescript/lib/modular.d.ts.map +1 -0
- package/dist/typescript/lib/namespaced.d.ts +11 -0
- package/dist/typescript/lib/namespaced.d.ts.map +1 -0
- package/dist/typescript/lib/polyfills.d.ts +2 -0
- package/dist/typescript/lib/polyfills.d.ts.map +1 -0
- package/dist/typescript/lib/polyfills.web.d.ts +1 -0
- package/dist/typescript/lib/polyfills.web.d.ts.map +1 -0
- package/dist/typescript/lib/statics.d.ts +12 -0
- package/dist/typescript/lib/statics.d.ts.map +1 -0
- package/dist/typescript/lib/types/internal.d.ts +94 -0
- package/dist/typescript/lib/types/internal.d.ts.map +1 -0
- package/dist/typescript/lib/types/namespaced.d.ts +124 -0
- package/dist/typescript/lib/types/namespaced.d.ts.map +1 -0
- package/dist/typescript/lib/types/remote-config.d.ts +37 -0
- package/dist/typescript/lib/types/remote-config.d.ts.map +1 -0
- package/dist/typescript/lib/version.d.ts +2 -0
- package/dist/typescript/lib/version.d.ts.map +1 -0
- package/dist/typescript/lib/web/RNFBConfigModule.android.d.ts +3 -0
- package/dist/typescript/lib/web/RNFBConfigModule.android.d.ts.map +1 -0
- package/dist/typescript/lib/web/RNFBConfigModule.d.ts +17 -0
- package/dist/typescript/lib/web/RNFBConfigModule.d.ts.map +1 -0
- package/dist/typescript/lib/web/RNFBConfigModule.ios.d.ts +3 -0
- package/dist/typescript/lib/web/RNFBConfigModule.ios.d.ts.map +1 -0
- package/dist/typescript/package.json +1 -0
- package/ios/RNFBConfig/RNFBConfigModule.m +10 -4
- package/lib/RemoteConfigValue.ts +66 -0
- package/lib/index.ts +25 -0
- package/lib/modular.ts +197 -0
- package/lib/namespaced.ts +552 -0
- package/lib/polyfills.ts +54 -0
- package/lib/statics.ts +27 -0
- package/lib/types/internal.ts +165 -0
- package/lib/types/namespaced.ts +163 -0
- package/lib/types/remote-config.ts +63 -0
- package/lib/version.ts +2 -0
- package/lib/web/RNFBConfigModule.android.ts +4 -0
- package/lib/web/RNFBConfigModule.ios.ts +4 -0
- package/lib/web/RNFBConfigModule.ts +254 -0
- package/package.json +42 -9
- package/tsconfig.json +21 -0
- package/typedoc.json +2 -3
- package/lib/RemoteConfigValue.js +0 -51
- package/lib/index.d.ts +0 -659
- package/lib/index.js +0 -400
- package/lib/modular/index.d.ts +0 -265
- package/lib/modular/index.js +0 -289
- package/lib/version.js +0 -2
- package/lib/web/RNFBConfigModule.android.js +0 -2
- package/lib/web/RNFBConfigModule.ios.js +0 -2
- /package/lib/{polyfills.web.js → polyfills.web.ts} +0 -0
package/lib/index.js
DELETED
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this library except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
hasOwnProperty,
|
|
20
|
-
isNumber,
|
|
21
|
-
isObject,
|
|
22
|
-
isString,
|
|
23
|
-
isUndefined,
|
|
24
|
-
isIOS,
|
|
25
|
-
isFunction,
|
|
26
|
-
parseListenerOrObserver,
|
|
27
|
-
} from '@react-native-firebase/app/dist/module/common';
|
|
28
|
-
import Value from './RemoteConfigValue';
|
|
29
|
-
import {
|
|
30
|
-
createModuleNamespace,
|
|
31
|
-
FirebaseModule,
|
|
32
|
-
getFirebaseRoot,
|
|
33
|
-
} from '@react-native-firebase/app/dist/module/internal';
|
|
34
|
-
import { setReactNativeModule } from '@react-native-firebase/app/dist/module/internal/nativeModule';
|
|
35
|
-
import fallBackModule from './web/RNFBConfigModule';
|
|
36
|
-
import version from './version';
|
|
37
|
-
import { LastFetchStatus, ValueSource } from './statics';
|
|
38
|
-
|
|
39
|
-
const statics = {
|
|
40
|
-
LastFetchStatus,
|
|
41
|
-
ValueSource,
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const namespace = 'remoteConfig';
|
|
45
|
-
const nativeModuleName = 'RNFBConfigModule';
|
|
46
|
-
|
|
47
|
-
class FirebaseConfigModule extends FirebaseModule {
|
|
48
|
-
constructor(...args) {
|
|
49
|
-
super(...args);
|
|
50
|
-
this._settings = {
|
|
51
|
-
// defaults to 1 minute.
|
|
52
|
-
fetchTimeMillis: 60000,
|
|
53
|
-
// defaults to 12 hours.
|
|
54
|
-
minimumFetchIntervalMillis: 43200000,
|
|
55
|
-
};
|
|
56
|
-
this._lastFetchTime = -1;
|
|
57
|
-
this._values = {};
|
|
58
|
-
this._configUpdateListenerCount = 0;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
get defaultConfig() {
|
|
62
|
-
const updatedDefaultConfig = {};
|
|
63
|
-
Object.keys(this._values).forEach(key => {
|
|
64
|
-
// Need to make it an object with key and literal value. Not `Value` instance.
|
|
65
|
-
updatedDefaultConfig[key] = this._values[key].value;
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
return updatedDefaultConfig;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
set defaultConfig(defaults) {
|
|
72
|
-
if (!isObject(defaults)) {
|
|
73
|
-
throw new Error("firebase.remoteConfig().defaultConfig: 'defaults' must be an object.");
|
|
74
|
-
}
|
|
75
|
-
// To make Firebase web v9 API compatible, we update the config first so it immediately
|
|
76
|
-
// updates defaults on the instance. We then pass to underlying SDK to update. We do this because
|
|
77
|
-
// there is no way to "await" a setter.
|
|
78
|
-
this._updateFromConstants(defaults);
|
|
79
|
-
this.setDefaults.call(this, defaults, true);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
get settings() {
|
|
83
|
-
return this._settings;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
set settings(settings) {
|
|
87
|
-
// To make Firebase web v9 API compatible, we update the settings first so it immediately
|
|
88
|
-
// updates settings on the instance. We then pass to underlying SDK to update. We do this because
|
|
89
|
-
// there is no way to "await" a setter. We can't delegate to `setConfigSettings()` as it is setup
|
|
90
|
-
// for native.
|
|
91
|
-
this._updateFromConstants(settings);
|
|
92
|
-
this.setConfigSettings.call(this, settings, true);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
getValue(key) {
|
|
96
|
-
if (!isString(key)) {
|
|
97
|
-
throw new Error("firebase.remoteConfig().getValue(): 'key' must be a string value.");
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (typeof this._values === 'undefined' || !hasOwnProperty(this._values, key)) {
|
|
101
|
-
return new Value({
|
|
102
|
-
value: '',
|
|
103
|
-
source: 'static',
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return new Value({ value: `${this._values[key].value}`, source: this._values[key].source });
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
getBoolean(key) {
|
|
111
|
-
return this.getValue(key).asBoolean();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
getNumber(key) {
|
|
115
|
-
return this.getValue(key).asNumber();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
getString(key) {
|
|
119
|
-
return this.getValue(key).asString();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
getAll() {
|
|
123
|
-
const values = {};
|
|
124
|
-
Object.keys(this._values).forEach(key => (values[key] = this.getValue(key)));
|
|
125
|
-
return values;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
get fetchTimeMillis() {
|
|
129
|
-
// android returns -1 if no fetch yet and iOS returns 0
|
|
130
|
-
return this._lastFetchTime;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
get lastFetchStatus() {
|
|
134
|
-
return this._lastFetchStatus;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Deletes all activated, fetched and defaults configs and resets all Firebase Remote Config settings.
|
|
139
|
-
* @returns {Promise<null>}
|
|
140
|
-
*/
|
|
141
|
-
reset() {
|
|
142
|
-
if (isIOS) {
|
|
143
|
-
return Promise.resolve(null);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return this._promiseWithConstants(this.native.reset());
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
setConfigSettings(settings) {
|
|
150
|
-
const updatedSettings = {};
|
|
151
|
-
|
|
152
|
-
updatedSettings.fetchTimeout = this._settings.fetchTimeMillis / 1000;
|
|
153
|
-
updatedSettings.minimumFetchInterval = this._settings.minimumFetchIntervalMillis / 1000;
|
|
154
|
-
|
|
155
|
-
const apiCalled = arguments[1] == true ? 'settings' : 'setConfigSettings';
|
|
156
|
-
if (!isObject(settings)) {
|
|
157
|
-
throw new Error(`firebase.remoteConfig().${apiCalled}(*): settings must set an object.`);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (hasOwnProperty(settings, 'minimumFetchIntervalMillis')) {
|
|
161
|
-
if (!isNumber(settings.minimumFetchIntervalMillis)) {
|
|
162
|
-
throw new Error(
|
|
163
|
-
`firebase.remoteConfig().${apiCalled}(): 'settings.minimumFetchIntervalMillis' must be a number type in milliseconds.`,
|
|
164
|
-
);
|
|
165
|
-
} else {
|
|
166
|
-
updatedSettings.minimumFetchInterval = settings.minimumFetchIntervalMillis / 1000;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (hasOwnProperty(settings, 'fetchTimeMillis')) {
|
|
171
|
-
if (!isNumber(settings.fetchTimeMillis)) {
|
|
172
|
-
throw new Error(
|
|
173
|
-
`firebase.remoteConfig().${apiCalled}(): 'settings.fetchTimeMillis' must be a number type in milliseconds.`,
|
|
174
|
-
);
|
|
175
|
-
} else {
|
|
176
|
-
updatedSettings.fetchTimeout = settings.fetchTimeMillis / 1000;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return this._promiseWithConstants(this.native.setConfigSettings(updatedSettings));
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Activates the Fetched RemoteConfig, so that the fetched key-values take effect.
|
|
185
|
-
* @returns {Promise<boolean>}
|
|
186
|
-
*/
|
|
187
|
-
activate() {
|
|
188
|
-
return this._promiseWithConstants(this.native.activate());
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Fetches parameter values for your app.
|
|
193
|
-
|
|
194
|
-
* @param {number} expirationDurationSeconds
|
|
195
|
-
* @returns {Promise}
|
|
196
|
-
*/
|
|
197
|
-
fetch(expirationDurationSeconds) {
|
|
198
|
-
if (!isUndefined(expirationDurationSeconds) && !isNumber(expirationDurationSeconds)) {
|
|
199
|
-
throw new Error(
|
|
200
|
-
"firebase.remoteConfig().fetch(): 'expirationDurationSeconds' must be a number value.",
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return this._promiseWithConstants(
|
|
205
|
-
this.native.fetch(expirationDurationSeconds !== undefined ? expirationDurationSeconds : -1),
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
fetchAndActivate() {
|
|
210
|
-
return this._promiseWithConstants(this.native.fetchAndActivate());
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
ensureInitialized() {
|
|
214
|
-
return this._promiseWithConstants(this.native.ensureInitialized());
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Sets defaults.
|
|
219
|
-
*
|
|
220
|
-
* @param {object} defaults
|
|
221
|
-
*/
|
|
222
|
-
setDefaults(defaults) {
|
|
223
|
-
const apiCalled = arguments[1] === true ? 'defaultConfig' : 'setDefaults';
|
|
224
|
-
if (!isObject(defaults)) {
|
|
225
|
-
throw new Error(`firebase.remoteConfig().${apiCalled}(): 'defaults' must be an object.`);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return this._promiseWithConstants(this.native.setDefaults(defaults));
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Sets defaults based on resource.
|
|
233
|
-
* @param {string} resourceName
|
|
234
|
-
*/
|
|
235
|
-
setDefaultsFromResource(resourceName) {
|
|
236
|
-
if (!isString(resourceName)) {
|
|
237
|
-
throw new Error(
|
|
238
|
-
"firebase.remoteConfig().setDefaultsFromResource(): 'resourceName' must be a string value.",
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
return this._promiseWithConstants(this.native.setDefaultsFromResource(resourceName));
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Registers an observer to changes in the configuration.
|
|
247
|
-
*
|
|
248
|
-
* @param observer - The {@link ConfigUpdateObserver} to be notified of config updates.
|
|
249
|
-
* @returns An {@link Unsubscribe} function to remove the listener.
|
|
250
|
-
*/
|
|
251
|
-
onConfigUpdate(observer) {
|
|
252
|
-
if (!isObject(observer) || !isFunction(observer.next) || !isFunction(observer.error)) {
|
|
253
|
-
throw new Error("'observer' expected an object with 'next' and 'error' functions.");
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// We maintaine our pre-web-support native interface but bend it to match
|
|
257
|
-
// the official JS SDK API by assuming the callback is an Observer, and sending it a ConfigUpdate
|
|
258
|
-
// compatible parameter that implements the `getUpdatedKeys` method
|
|
259
|
-
let unsubscribed = false;
|
|
260
|
-
const subscription = this.emitter.addListener(
|
|
261
|
-
this.eventNameForApp('on_config_updated'),
|
|
262
|
-
event => {
|
|
263
|
-
const { resultType } = event;
|
|
264
|
-
if (resultType === 'success') {
|
|
265
|
-
observer.next({
|
|
266
|
-
getUpdatedKeys: () => {
|
|
267
|
-
return new Set(event.updatedKeys);
|
|
268
|
-
},
|
|
269
|
-
});
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
observer.error({
|
|
274
|
-
code: event.code,
|
|
275
|
-
message: event.message,
|
|
276
|
-
nativeErrorMessage: event.nativeErrorMessage,
|
|
277
|
-
});
|
|
278
|
-
},
|
|
279
|
-
);
|
|
280
|
-
if (this._configUpdateListenerCount === 0) {
|
|
281
|
-
this.native.onConfigUpdated();
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
this._configUpdateListenerCount++;
|
|
285
|
-
|
|
286
|
-
return () => {
|
|
287
|
-
if (unsubscribed) {
|
|
288
|
-
// there is no harm in calling this multiple times to unsubscribe,
|
|
289
|
-
// but anything after the first call is a no-op
|
|
290
|
-
return;
|
|
291
|
-
} else {
|
|
292
|
-
unsubscribed = true;
|
|
293
|
-
}
|
|
294
|
-
subscription.remove();
|
|
295
|
-
this._configUpdateListenerCount--;
|
|
296
|
-
if (this._configUpdateListenerCount === 0) {
|
|
297
|
-
this.native.removeConfigUpdateRegistration();
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Registers a listener to changes in the configuration.
|
|
304
|
-
*
|
|
305
|
-
* @param listenerOrObserver - function called on config change
|
|
306
|
-
* @returns {function} unsubscribe listener
|
|
307
|
-
* @deprecated use official firebase-js-sdk onConfigUpdate now that web supports realtime
|
|
308
|
-
*/
|
|
309
|
-
onConfigUpdated(listenerOrObserver) {
|
|
310
|
-
const listener = parseListenerOrObserver(listenerOrObserver);
|
|
311
|
-
let unsubscribed = false;
|
|
312
|
-
const subscription = this.emitter.addListener(
|
|
313
|
-
this.eventNameForApp('on_config_updated'),
|
|
314
|
-
event => {
|
|
315
|
-
const { resultType } = event;
|
|
316
|
-
if (resultType === 'success') {
|
|
317
|
-
listener({ updatedKeys: event.updatedKeys }, undefined);
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
listener(undefined, {
|
|
322
|
-
code: event.code,
|
|
323
|
-
message: event.message,
|
|
324
|
-
nativeErrorMessage: event.nativeErrorMessage,
|
|
325
|
-
});
|
|
326
|
-
},
|
|
327
|
-
);
|
|
328
|
-
if (this._configUpdateListenerCount === 0) {
|
|
329
|
-
this.native.onConfigUpdated();
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
this._configUpdateListenerCount++;
|
|
333
|
-
|
|
334
|
-
return () => {
|
|
335
|
-
if (unsubscribed) {
|
|
336
|
-
// there is no harm in calling this multiple times to unsubscribe,
|
|
337
|
-
// but anything after the first call is a no-op
|
|
338
|
-
return;
|
|
339
|
-
} else {
|
|
340
|
-
unsubscribed = true;
|
|
341
|
-
}
|
|
342
|
-
subscription.remove();
|
|
343
|
-
this._configUpdateListenerCount--;
|
|
344
|
-
if (this._configUpdateListenerCount === 0) {
|
|
345
|
-
this.native.removeConfigUpdateRegistration();
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
_updateFromConstants(constants) {
|
|
351
|
-
// Wrapped this as we update using sync getters initially for `defaultConfig` & `settings`
|
|
352
|
-
if (constants.lastFetchTime) {
|
|
353
|
-
this._lastFetchTime = constants.lastFetchTime;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
// Wrapped this as we update using sync getters initially for `defaultConfig` & `settings`
|
|
357
|
-
if (constants.lastFetchStatus) {
|
|
358
|
-
this._lastFetchStatus = constants.lastFetchStatus;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
this._settings = {
|
|
362
|
-
fetchTimeMillis: constants.fetchTimeout * 1000,
|
|
363
|
-
minimumFetchIntervalMillis: constants.minimumFetchInterval * 1000,
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
this._values = Object.freeze(constants.values);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
_promiseWithConstants(promise) {
|
|
370
|
-
return promise.then(({ result, constants }) => {
|
|
371
|
-
this._updateFromConstants(constants);
|
|
372
|
-
return result;
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
// import { SDK_VERSION } from '@react-native-firebase/remote-config';
|
|
378
|
-
export const SDK_VERSION = version;
|
|
379
|
-
|
|
380
|
-
// import config from '@react-native-firebase/remote-config';
|
|
381
|
-
// config().X(...);
|
|
382
|
-
export default createModuleNamespace({
|
|
383
|
-
statics,
|
|
384
|
-
version,
|
|
385
|
-
namespace,
|
|
386
|
-
nativeModuleName,
|
|
387
|
-
nativeEvents: ['on_config_updated'],
|
|
388
|
-
hasMultiAppSupport: true,
|
|
389
|
-
hasCustomUrlOrRegionSupport: false,
|
|
390
|
-
ModuleClass: FirebaseConfigModule,
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
export * from './modular';
|
|
394
|
-
|
|
395
|
-
// import config, { firebase } from '@react-native-firebase/remote-config';
|
|
396
|
-
// config().X(...);
|
|
397
|
-
// firebase.remoteConfig().X(...);
|
|
398
|
-
export const firebase = getFirebaseRoot();
|
|
399
|
-
|
|
400
|
-
setReactNativeModule(nativeModuleName, fallBackModule);
|
package/lib/modular/index.d.ts
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this library except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
import { ReactNativeFirebase } from '@react-native-firebase/app';
|
|
18
|
-
import { FirebaseRemoteConfigTypes } from '..';
|
|
19
|
-
|
|
20
|
-
import RemoteConfig = FirebaseRemoteConfigTypes.Module;
|
|
21
|
-
import ConfigValues = FirebaseRemoteConfigTypes.ConfigValues;
|
|
22
|
-
import ConfigValue = FirebaseRemoteConfigTypes.ConfigValue;
|
|
23
|
-
import ConfigDefaults = FirebaseRemoteConfigTypes.ConfigDefaults;
|
|
24
|
-
import ConfigSettings = FirebaseRemoteConfigTypes.ConfigSettings;
|
|
25
|
-
import LastFetchStatusType = FirebaseRemoteConfigTypes.LastFetchStatusType;
|
|
26
|
-
import RemoteConfigLogLevel = FirebaseRemoteConfigTypes.RemoteConfigLogLevel;
|
|
27
|
-
import FirebaseApp = ReactNativeFirebase.FirebaseApp;
|
|
28
|
-
import LastFetchStatusInterface = FirebaseRemoteConfigTypes.LastFetchStatus;
|
|
29
|
-
import ValueSourceInterface = FirebaseRemoteConfigTypes.ValueSource;
|
|
30
|
-
import ConfigUpdateObserver = FirebaseRemoteConfigTypes.ConfigUpdateObserver;
|
|
31
|
-
import Unsubscribe = FirebaseRemoteConfigTypes.Unsubscribe;
|
|
32
|
-
// deprecated: from pre-Web realtime remote-config support - remove with onConfigUpdated
|
|
33
|
-
import CallbackOrObserver = FirebaseRemoteConfigTypes.CallbackOrObserver;
|
|
34
|
-
// deprecated: from pre-Web realtime remote-config support - remove with onConfigUpdated
|
|
35
|
-
import OnConfigUpdatedListenerCallback = FirebaseRemoteConfigTypes.OnConfigUpdatedListenerCallback;
|
|
36
|
-
|
|
37
|
-
export const LastFetchStatus: LastFetchStatusInterface;
|
|
38
|
-
export const ValueSource: ValueSourceInterface;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Returns a RemoteConfig instance for the given app.
|
|
42
|
-
* @param app - FirebaseApp. Optional.
|
|
43
|
-
* @returns {RemoteConfig}
|
|
44
|
-
*/
|
|
45
|
-
export function getRemoteConfig(app?: FirebaseApp): RemoteConfig;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Returns a Boolean which resolves to true if the current call
|
|
49
|
-
* activated the fetched configs.
|
|
50
|
-
* @param remoteConfig - RemoteConfig instance
|
|
51
|
-
* @returns {Promise<boolean>}
|
|
52
|
-
*/
|
|
53
|
-
export function activate(remoteConfig: RemoteConfig): Promise<boolean>;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Ensures the last activated config are available to the getters.
|
|
57
|
-
* @param remoteConfig - RemoteConfig instance
|
|
58
|
-
* @returns {Promise<void>}
|
|
59
|
-
*/
|
|
60
|
-
export function ensureInitialized(remoteConfig: RemoteConfig): Promise<void>;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Performs a fetch and returns a Boolean which resolves to true
|
|
64
|
-
* if the current call activated the fetched configs.
|
|
65
|
-
* @param remoteConfig - RemoteConfig instance
|
|
66
|
-
* @returns {Promise<boolean>}
|
|
67
|
-
*/
|
|
68
|
-
export function fetchAndActivate(remoteConfig: RemoteConfig): Promise<boolean>;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Fetches and caches configuration from the Remote Config service.
|
|
72
|
-
* @param remoteConfig - RemoteConfig instance
|
|
73
|
-
* @returns {Promise<void>}
|
|
74
|
-
*/
|
|
75
|
-
export function fetchConfig(remoteConfig: RemoteConfig): Promise<void>;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Gets all config.
|
|
79
|
-
* @param remoteConfig - RemoteConfig instance
|
|
80
|
-
* @returns {ConfigValues}
|
|
81
|
-
*/
|
|
82
|
-
export function getAll(remoteConfig: RemoteConfig): ConfigValues;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Gets the value for the given key as a boolean.
|
|
86
|
-
* @param remoteConfig - RemoteConfig instance
|
|
87
|
-
* @param key - key for boolean value
|
|
88
|
-
* @returns {boolean}
|
|
89
|
-
*/
|
|
90
|
-
export function getBoolean(remoteConfig: RemoteConfig, key: string): boolean;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Gets the value for the given key as a number.
|
|
94
|
-
* @param remoteConfig - RemoteConfig instance
|
|
95
|
-
* @param key - key for number value
|
|
96
|
-
* @returns {number}
|
|
97
|
-
*/
|
|
98
|
-
export function getNumber(remoteConfig: RemoteConfig, key: string): number;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Gets the value for the given key as a string.
|
|
102
|
-
* @param remoteConfig - RemoteConfig instance
|
|
103
|
-
* @param key - key for string value
|
|
104
|
-
* @returns {string}
|
|
105
|
-
*/
|
|
106
|
-
export function getString(remoteConfig: RemoteConfig, key: string): string;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Gets the value for the given key
|
|
110
|
-
* @param remoteConfig - RemoteConfig instance
|
|
111
|
-
* @param key - key for the given value
|
|
112
|
-
* @returns {ConfigValue}
|
|
113
|
-
*/
|
|
114
|
-
export function getValue(remoteConfig: RemoteConfig, key: string): ConfigValue;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Defines the log level to use.
|
|
118
|
-
* @param remoteConfig - RemoteConfig instance
|
|
119
|
-
* @param logLevel - The log level to set
|
|
120
|
-
* @returns {RemoteConfigLogLevel}
|
|
121
|
-
*/
|
|
122
|
-
export function setLogLevel(
|
|
123
|
-
remoteConfig: RemoteConfig,
|
|
124
|
-
logLevel: RemoteConfigLogLevel,
|
|
125
|
-
): RemoteConfigLogLevel;
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Checks two different things.
|
|
129
|
-
* 1. Check if IndexedDB exists in the browser environment.
|
|
130
|
-
* 2. Check if the current browser context allows IndexedDB open() calls.
|
|
131
|
-
* @returns {Promise<boolean>}
|
|
132
|
-
*/
|
|
133
|
-
export function isSupported(): Promise<boolean>;
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Indicates the default value in milliseconds to abandon a pending fetch
|
|
137
|
-
* request made to the Remote Config server. Defaults to 60000 (One minute).
|
|
138
|
-
* @param remoteConfig - RemoteConfig instance
|
|
139
|
-
* @returns {number}
|
|
140
|
-
*/
|
|
141
|
-
export function fetchTimeMillis(remoteConfig: RemoteConfig): number;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Returns a ConfigSettings object which provides the properties `minimumFetchIntervalMillis` & `fetchTimeMillis` if they have been set
|
|
145
|
-
* using setConfigSettings({ fetchTimeMillis: number, minimumFetchIntervalMillis: number }).
|
|
146
|
-
* @param remoteConfig - RemoteConfig instance
|
|
147
|
-
* @returns {ConfigSettings}
|
|
148
|
-
*/
|
|
149
|
-
export function settings(remoteConfig: RemoteConfig): ConfigSettings;
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* The status of the latest Remote RemoteConfig fetch action.
|
|
153
|
-
* @param remoteConfig - RemoteConfig instance
|
|
154
|
-
* @returns {LastFetchStatusType}
|
|
155
|
-
*/
|
|
156
|
-
export function lastFetchStatus(remoteConfig: RemoteConfig): LastFetchStatusType;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Deletes all activated, fetched and defaults configs and
|
|
160
|
-
* resets all Firebase Remote Config settings.
|
|
161
|
-
* Android only. iOS does not reset anything.
|
|
162
|
-
* @param remoteConfig - RemoteConfig instance
|
|
163
|
-
* @returns {Promise<void>}
|
|
164
|
-
*/
|
|
165
|
-
export function reset(remoteConfig: RemoteConfig): Promise<void>;
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Set the Remote RemoteConfig settings, currently able to set
|
|
169
|
-
* `fetchTimeMillis` & `minimumFetchIntervalMillis`
|
|
170
|
-
* @param remoteConfig - RemoteConfig instance
|
|
171
|
-
* @param settings - ConfigSettings instance
|
|
172
|
-
* @returns {Promise<void>}
|
|
173
|
-
*/
|
|
174
|
-
export function setConfigSettings(
|
|
175
|
-
remoteConfig: RemoteConfig,
|
|
176
|
-
settings: ConfigSettings,
|
|
177
|
-
): Promise<void>;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Fetches parameter values for your app.
|
|
181
|
-
* @param remoteConfig - RemoteConfig instance
|
|
182
|
-
* @param expirationDurationSeconds - number
|
|
183
|
-
* @returns {Promise<void>}
|
|
184
|
-
*/
|
|
185
|
-
export function fetch(
|
|
186
|
-
remoteConfig: RemoteConfig,
|
|
187
|
-
expirationDurationSeconds?: number,
|
|
188
|
-
): Promise<void>;
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Fetches parameter values for your app.
|
|
192
|
-
* @param remoteConfig - RemoteConfig instance
|
|
193
|
-
* @param defaults - ConfigDefaults
|
|
194
|
-
* @returns {Promise<void>}
|
|
195
|
-
*/
|
|
196
|
-
export function setDefaults(remoteConfig: RemoteConfig, defaults: ConfigDefaults): Promise<void>;
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Fetches parameter values for your app.
|
|
200
|
-
* @param remoteConfig - RemoteConfig instance
|
|
201
|
-
* @param resourceName - string
|
|
202
|
-
* @returns {Promise<null>}
|
|
203
|
-
*/
|
|
204
|
-
export function setDefaultsFromResource(
|
|
205
|
-
remoteConfig: RemoteConfig,
|
|
206
|
-
resourceName: string,
|
|
207
|
-
): Promise<null>;
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Starts listening for real-time config updates from the Remote Config backend and automatically
|
|
211
|
-
* fetches updates from the Remote Config backend when they are available.
|
|
212
|
-
*
|
|
213
|
-
* @remarks
|
|
214
|
-
* If a connection to the Remote Config backend is not already open, calling this method will
|
|
215
|
-
* open it. Multiple listeners can be added by calling this method again, but subsequent calls
|
|
216
|
-
* re-use the same connection to the backend.
|
|
217
|
-
*
|
|
218
|
-
* The list of updated keys passed to the callback will include all keys not currently active,
|
|
219
|
-
* and the config update process fetches the new config but does not automatically activate
|
|
220
|
-
* it for you. Typically you will activate the config in your callback to use the new values.
|
|
221
|
-
*
|
|
222
|
-
* @param remoteConfig - The {@link RemoteConfig} instance.
|
|
223
|
-
* @param observer - The {@link ConfigUpdateObserver} to be notified of config updates.
|
|
224
|
-
* @returns An {@link Unsubscribe} function to remove the listener.
|
|
225
|
-
*/
|
|
226
|
-
export function onConfigUpdate(
|
|
227
|
-
remoteConfig: RemoteConfig,
|
|
228
|
-
observer: ConfigUpdateObserver,
|
|
229
|
-
): Unsubscribe;
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Registers a listener to changes in the configuration.
|
|
233
|
-
*
|
|
234
|
-
* @param remoteConfig - RemoteConfig instance
|
|
235
|
-
* @param callback - function called on config change
|
|
236
|
-
* @returns {function} unsubscribe listener
|
|
237
|
-
* @deprecated use official firebase-js-sdk onConfigUpdate now that web supports realtime
|
|
238
|
-
*/
|
|
239
|
-
export function onConfigUpdated(
|
|
240
|
-
remoteConfig: RemoteConfig,
|
|
241
|
-
callback: CallbackOrObserver<OnConfigUpdatedListenerCallback>,
|
|
242
|
-
): () => void;
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Defines the type for representing custom signals and their values.
|
|
246
|
-
* The values in CustomSignals must be one of the following types: string, number, or null.
|
|
247
|
-
* There are additional limitations on key and value length, for a full description see https://firebase.google.com/docs/remote-config/parameters?template_type=client#custom_signal_conditions
|
|
248
|
-
* Failing to stay within these limitations will result in a silent API failure with only a warning in device logs
|
|
249
|
-
*/
|
|
250
|
-
|
|
251
|
-
export interface CustomSignals {
|
|
252
|
-
[key: string]: string | number | null;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Sets the custom signals for the app instance.
|
|
257
|
-
* @param {RemoteConfig} remoteConfig - RemoteConfig instance
|
|
258
|
-
* @param {CustomSignals} customSignals - CustomSignals
|
|
259
|
-
* @returns {Promise<void>}
|
|
260
|
-
*/
|
|
261
|
-
|
|
262
|
-
export declare function setCustomSignals(
|
|
263
|
-
remoteConfig: RemoteConfig,
|
|
264
|
-
customSignals: CustomSignals,
|
|
265
|
-
): Promise<void>;
|