-
Notifications
You must be signed in to change notification settings - Fork 254
/
Copy pathindex.js
53 lines (44 loc) · 1.32 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// [SNIPPET_REGISTRY disabled]
// [SNIPPETS_SEPARATION enabled]
function getInstance() {
// [START rc_get_instance]
const { getRemoteConfig } = require("firebase/remote-config");
const remoteConfig = getRemoteConfig();
// [END rc_get_instance]
return remoteConfig;
}
function setMinimumFetchTime() {
const remoteConfig = getInstance();
// [START rc_set_minimum_fetch_time]
// The default and recommended production fetch interval for Remote Config is 12 hours
remoteConfig.settings.minimumFetchIntervalMillis = 3600000;
// [END rc_set_minimum_fetch_time]
}
function setDefaultValues() {
const remoteConfig = getInstance();
// [START rc_set_default_values]
remoteConfig.defaultConfig = {
"welcome_message": "Welcome"
};
// [END rc_set_default_values]
}
function getValues() {
const remoteConfig = getInstance();
// [START rc_get_values]
const { getValue } = require("firebase/remote-config");
const val = getValue(remoteConfig, "welcome_messsage");
// [END rc_get_values]
}
function fetchConfigCallback() {
const remoteConfig = getInstance();
// [START rc_fetch_config_callback]
const { fetchAndActivate } = require("firebase/remote-config");
fetchAndActivate(remoteConfig)
.then(() => {
// ...
})
.catch((err) => {
// ...
});
// [END rc_fetch_config_callback]
}