Skip to content

Commit 56cf551

Browse files
committed
Initial check-in with remoteConfig
1 parent 075e560 commit 56cf551

File tree

19 files changed

+784
-377
lines changed

19 files changed

+784
-377
lines changed

firestack.ios.js

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,45 @@ const promisify = fn => (...args) => {
2020
});
2121
};
2222

23+
/**
24+
* Configuration class
25+
*/
26+
const defaultExpiration = 60 * 60 * 24; // one day
27+
class RemoteConfig {
28+
constructor(options) {
29+
this.config = options || {};
30+
31+
this.setDefaultRemoteConfig(options)
32+
.then(() => this.configured = true);
33+
}
34+
35+
setDefaultRemoteConfig(options) {
36+
return promisify('setDefaultRemoteConfig')(options);
37+
}
38+
39+
fetchWithExpiration(expirationSeconds=defaultExpiration) {
40+
return promisify('fetchWithExpiration')(expirationSeconds)
41+
}
42+
43+
config(name) {
44+
return promisify('configValueForKey')(name);
45+
}
46+
47+
setDev() {
48+
return promisify('setDev')();
49+
}
50+
}
51+
2352
export default class Firestack {
2453
constructor(options) {
2554
this.options = options || {};
55+
56+
this._remoteConfig = options.remoteConfig || {};
57+
delete options.remoteConfig;
58+
2659
this.appInstance = app.initializeApp(options);
2760
this.configured = false;
61+
this._debug = options.debug || false;
2862

2963
this.eventHandlers = {};
3064
}
@@ -174,15 +208,15 @@ export default class Firestack {
174208
}
175209

176210
// Storage
177-
178-
/**
179-
* Configure the library to store the storage url
180-
* @param {string} url A string of your firebase storage url
181-
* @return {Promise}
182-
*/
183-
setStorageUrl(url) {
184-
return promisify('setStorageUrl')(url);
185-
}
211+
//
212+
// /**
213+
// * Configure the library to store the storage url
214+
// * @param {string} url A string of your firebase storage url
215+
// * @return {Promise}
216+
// */
217+
// setStorageUrl(url) {
218+
// return promisify('setStorageUrl')(url);
219+
// }
186220

187221
/**
188222
* Upload a filepath
@@ -197,7 +231,8 @@ export default class Firestack {
197231

198232
// database
199233
get database() {
200-
return db();
234+
db.enableLogging(this._debug);
235+
return db()
201236
}
202237

203238
/**
@@ -213,6 +248,16 @@ export default class Firestack {
213248
return db.ServerValue;
214249
}
215250

251+
/**
252+
* remote config
253+
*/
254+
get remoteConfig() {
255+
if (!this.remoteConfig) {
256+
this.remoteConfig = new RemoteConfig(this._remoteConfig);
257+
}
258+
return this.remoteConfig;
259+
}
260+
216261
on(name, cb) {
217262
if (!this.eventHandlers[name]) {
218263
this.eventHandlers[name] = [];

ios/Firestack/Firestack.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
@property (nonatomic) BOOL debug;
1717
@property (atomic) BOOL configured;
1818
@property (nonatomic, strong) NSDictionary *configuration;
19+
@property (nonatomic, strong) FIRRemoteConfig *remoteConfigInstance;
1920

2021
@end

0 commit comments

Comments
 (0)