@@ -24,14 +24,14 @@ - (void)dealloc
24
24
}
25
25
26
26
// TODO: Implement
27
- + (void ) setup : (UIApplication *) application
27
+ + (void ) setup : (UIApplication *) application
28
28
withLaunchOptions : (NSDictionary *) launchOptions
29
29
{
30
30
NSLog (@" Called setup for firestack with application" );
31
-
31
+
32
32
dispatch_once (&onceToken, ^{
33
33
[application registerForRemoteNotifications ];
34
-
34
+
35
35
[[NSNotificationCenter defaultCenter ]
36
36
postNotificationName: kFirestackInitialized
37
37
object: nil ];
@@ -42,7 +42,7 @@ - (id) init
42
42
{
43
43
self = [super init ];
44
44
if (self != nil ) {
45
- NSLog (@" Setting up Firestace instance" );
45
+ NSLog (@" Setting up Firestack instance" );
46
46
[Firestack initializeFirestack: self ];
47
47
}
48
48
return self;
@@ -52,12 +52,7 @@ + (void) initializeFirestack:(Firestack *) instance
52
52
{
53
53
dispatch_once (&onceToken, ^{
54
54
_sharedInstance = instance;
55
-
56
- [[NSNotificationCenter defaultCenter ] addObserver: self
57
- selector: @selector (reloadFirestack )
58
- name: RCTReloadNotification
59
- object: nil ];
60
-
55
+
61
56
[[NSNotificationCenter defaultCenter ]
62
57
postNotificationName: kFirestackInitialized
63
58
object: nil ];
@@ -70,15 +65,6 @@ + (instancetype) sharedInstance
70
65
return _sharedInstance;
71
66
}
72
67
73
- + (void ) reloadFirestack
74
- {
75
- // Reloading firestack
76
- onceToken = 0 ; // not sure if this is a good idea or a bad idea...
77
- [[Firestack sharedInstance ] debugLog: @" Firestack"
78
- msg: @" Reloading firestack" ];
79
- _sharedInstance = nil ;
80
- }
81
-
82
68
- (FIRApp *) firebaseApp
83
69
{
84
70
return [FIRApp defaultApp ];
@@ -101,7 +87,7 @@ - (FIRApp *) firebaseApp
101
87
// Are we debugging, yo?
102
88
self.debug = [opts valueForKey: @" debug" ] != nil ? YES : NO ;
103
89
NSLog (@" options passed into configureWithOptions: %@ " , [opts valueForKey: @" debug" ]);
104
-
90
+
105
91
NSDictionary *keyMapping = @{
106
92
@" GOOGLE_APP_ID" : @[
107
93
@" appId" ,
@@ -158,18 +144,18 @@ - (FIRApp *) firebaseApp
158
144
]
159
145
};
160
146
NSArray *optionKeys = [keyMapping allKeys ];
161
-
147
+
162
148
NSMutableDictionary *props;
163
-
149
+
164
150
NSString *plistPath = [[NSBundle mainBundle ] pathForResource: @" GoogleService-Info" ofType: @" plist" ];
165
-
151
+
166
152
if ([[NSFileManager defaultManager ] fileExistsAtPath: plistPath]) {
167
153
// If the Firebase plist is included
168
154
props = [NSMutableDictionary dictionaryWithContentsOfFile: plistPath];
169
155
} else {
170
156
props = [[NSMutableDictionary alloc ] initWithCapacity: [optionKeys count ]];
171
157
}
172
-
158
+
173
159
// Bundle ID either from options OR from the main bundle
174
160
NSString *bundleID;
175
161
if ([opts valueForKey: @" bundleID" ]) {
@@ -178,7 +164,7 @@ - (FIRApp *) firebaseApp
178
164
bundleID = [[NSBundle mainBundle ] bundleIdentifier ];
179
165
}
180
166
[props setValue: bundleID forKey: @" BUNDLE_ID" ];
181
-
167
+
182
168
// Prefer the user configuration options over the default options
183
169
for (int i=0 ; i < [optionKeys count ]; i++) {
184
170
// Traditional for loop here
@@ -189,9 +175,9 @@ - (FIRApp *) firebaseApp
189
175
NSString *value = [opts valueForKey: key];
190
176
[props setValue: value forKey: key];
191
177
}
192
-
178
+
193
179
NSArray *possibleNames = [keyMapping objectForKey: key];
194
-
180
+
195
181
for (NSString *name in possibleNames) {
196
182
if ([opts valueForKey: name] != nil ) {
197
183
// The user passed this option in
@@ -205,7 +191,7 @@ - (FIRApp *) firebaseApp
205
191
NSLog (@" An error occurred: %@ " , err);
206
192
}
207
193
}
208
-
194
+
209
195
@try {
210
196
if (self.debug ) {
211
197
NSLog (@" props ->: %@ " , props);
@@ -220,7 +206,7 @@ - (FIRApp *) firebaseApp
220
206
NSLog (@" STORAGE_BUCKET: %@ " , [props valueForKey: @" STORAGE_BUCKET" ]);
221
207
NSLog (@" DEEP_LINK_SCHEME: %@ " , [props valueForKey: @" DEEP_LINK_SCHEME" ]);
222
208
}
223
-
209
+
224
210
FIROptions *finalOptions = [[FIROptions alloc ]
225
211
initWithGoogleAppID: [props valueForKey: @" GOOGLE_APP_ID" ]
226
212
bundleID: [props valueForKey: @" BUNDLE_ID" ]
@@ -232,16 +218,16 @@ - (FIRApp *) firebaseApp
232
218
databaseURL: [props valueForKey: @" DATABASE_URL" ]
233
219
storageBucket: [props valueForKey: @" STORAGE_BUCKET" ]
234
220
deepLinkURLScheme: [props valueForKey: @" DEEP_LINK_SCHEME" ]];
235
-
221
+
236
222
// Save configuration option
237
223
// NSDictionary *cfg = [self getConfig];
238
224
// [cfg setValuesForKeysWithDictionary:props];
239
-
225
+
240
226
// if (!self.configured) {
241
-
227
+
242
228
if ([FIRApp defaultApp ] == NULL ) {
243
229
[FIRApp configureWithOptions: finalOptions];
244
- }
230
+ }
245
231
[Firestack initializeFirestack: self ];
246
232
callback (@[[NSNull null ], props]);
247
233
}
@@ -382,8 +368,8 @@ - (void) debugLog:(NSString *)title
382
368
// Not sure how to get away from this... yet
383
369
- (NSArray <NSString *> *)supportedEvents {
384
370
return @[
385
- INITIALIZED_EVENT,
386
- DEBUG_EVENT,
371
+ INITIALIZED_EVENT,
372
+ DEBUG_EVENT,
387
373
AUTH_CHANGED_EVENT ];
388
374
}
389
375
0 commit comments