@@ -234,6 +234,17 @@ export class FirebaseApp {
234
234
}
235
235
}
236
236
237
+ const launchQueue = [ ] ;
238
+
239
+ declare const TNSFirebaseCore ;
240
+
241
+ const launchCallback = ( ) => {
242
+ launchQueue . forEach ( ( item ) => item ( ) ) ;
243
+ launchQueue . splice ( 0 ) ;
244
+ } ;
245
+
246
+ TNSFirebaseCore . setOnAppFinishLaunchingCallback ( launchCallback ) ;
247
+
237
248
export class Firebase {
238
249
constructor ( ) {
239
250
if ( firebaseInstance ) {
@@ -352,36 +363,32 @@ export class Firebase {
352
363
}
353
364
resolve ( fbApp ) ;
354
365
} catch ( e ) {
355
- reject ( new FirebaseError ( e . message ) )
366
+ reject ( new FirebaseError ( e . message ) ) ;
356
367
}
357
- }
368
+ } ;
358
369
359
370
if ( ! UIApplication . sharedApplication ) {
360
- Application . ios . addNotificationObserver (
361
- UIApplicationDidFinishLaunchingNotification ,
362
- ( notification ) => {
363
- initApp ( ) ;
364
- }
365
- )
371
+ launchQueue . push ( ( ) => {
372
+ initApp ( ) ;
373
+ } ) ;
366
374
} else {
367
375
initApp ( ) ;
368
376
}
369
- } )
377
+ } ) ;
370
378
}
371
379
372
380
initializeAppWithPath ( path : string , options : FirebaseOptions = null , config ?: FirebaseConfig ) {
373
381
return new Promise ( ( resolve , reject ) => {
374
382
const initApp = ( ) => {
375
383
try {
376
384
if ( path . startsWith ( 'res://' ) ) {
377
- path = NSBundle . mainBundle . pathForResourceOfType ( path . replace ( 'res://' , '' ) . replace ( '.plist' , '' ) , 'plist' )
385
+ path = NSBundle . mainBundle . pathForResourceOfType ( path . replace ( 'res://' , '' ) . replace ( '.plist' , '' ) , 'plist' ) ;
378
386
} else if ( path . startsWith ( '~/' ) ) {
379
387
path = knownFolders . currentApp ( ) . path + '/' + path . replace ( '~/' , '' ) ;
380
388
}
381
389
382
390
const nativeOptions = FIROptions . alloc ( ) . initWithContentsOfFile ( path ) ;
383
391
384
-
385
392
if ( options ?. apiKey ) {
386
393
nativeOptions . APIKey = options . apiKey ;
387
394
}
@@ -430,7 +437,6 @@ export class Firebase {
430
437
nativeOptions . trackingID = options . trackingId ;
431
438
}
432
439
433
-
434
440
FIRApp . configureWithOptions ( nativeOptions ) ;
435
441
436
442
const app = FIRApp . defaultApp ( ) ;
@@ -445,20 +451,17 @@ export class Firebase {
445
451
}
446
452
resolve ( fbApp ) ;
447
453
} catch ( e ) {
448
- reject ( new FirebaseError ( e . message ) )
454
+ reject ( new FirebaseError ( e . message ) ) ;
449
455
}
450
- }
456
+ } ;
451
457
if ( ! UIApplication . sharedApplication ) {
452
- Application . ios . addNotificationObserver (
453
- UIApplicationDidFinishLaunchingNotification ,
454
- ( notification ) => {
455
- initApp ( ) ;
456
- }
457
- )
458
+ launchQueue . push ( ( ) => {
459
+ initApp ( ) ;
460
+ } ) ;
458
461
} else {
459
462
initApp ( ) ;
460
463
}
461
- } )
464
+ } ) ;
462
465
}
463
466
}
464
467
0 commit comments