@@ -58,29 +58,40 @@ firebase.areNotificationsEnabled = firebaseMessaging.areNotificationsEnabled;
5858
5959firebase . functions  =  firebaseFunctions ; 
6060
61+ NSNotificationCenter . defaultCenter . addObserverForNameObjectQueueUsingBlock ( 
62+     UIApplicationDidFinishLaunchingNotification , 
63+     null , 
64+     NSOperationQueue . mainQueue , 
65+     appNotification  =>  { 
66+       if  ( ! firebase . _configured )  { 
67+         firebase . _configured  =  true ; 
68+         if  ( typeof  ( FIRApp )  !==  "undefined" )  { 
69+           FIRApp . configure ( ) ; 
70+         } 
71+       } 
72+     } ) ; 
73+ 
6174firebase . addAppDelegateMethods  =  appDelegate  =>  { 
6275  // we need the launchOptions for this one so it's a bit hard to use the UIApplicationDidFinishLaunchingNotification pattern we're using for other things 
63-   appDelegate . prototype . applicationDidFinishLaunchingWithOptions  =  ( application ,  launchOptions )  =>  { 
64-     if  ( ! firebase . _configured )  { 
65-       firebase . _configured  =  true ; 
66-       if  ( typeof  ( FIRApp )  !==  "undefined" )  { 
67-         FIRApp . configure ( ) ; 
76+   // however, let's not override 'applicationDidFinishLaunchingWithOptions' if we don't really need it: 
77+   if  ( typeof  ( FIRMessaging )  !==  "undefined"  ||  useExternalPushProvider  ||  typeof  ( FBSDKApplicationDelegate )  !==  "undefined" )  { 
78+     appDelegate . prototype . applicationDidFinishLaunchingWithOptions  =  ( application ,  launchOptions )  =>  { 
79+       // If the app was terminated and iOS is launching it in result of a push notification tapped by the user, this will hold the notification data. 
80+       if  ( launchOptions )  { 
81+         const  remoteNotification  =  launchOptions . objectForKey ( UIApplicationLaunchOptionsRemoteNotificationKey ) ; 
82+         if  ( remoteNotification )  { 
83+           firebaseMessaging . handleRemoteNotification ( application ,  remoteNotification ) ; 
84+         } 
6885      } 
69-     } 
7086
71-     // If the app was terminated and iOS is launching it in result of a push notification tapped by the user, this will hold the notification data. 
72-     if  ( launchOptions )  { 
73-       const  remoteNotification  =  launchOptions . objectForKey ( UIApplicationLaunchOptionsRemoteNotificationKey ) ; 
74-       if  ( remoteNotification )  { 
75-         firebaseMessaging . handleRemoteNotification ( application ,  remoteNotification ) ; 
87+       // Firebase Facebook authentication 
88+       if  ( typeof  ( FBSDKApplicationDelegate )  !==  "undefined" )  { 
89+         FBSDKApplicationDelegate . sharedInstance ( ) . applicationDidFinishLaunchingWithOptions ( application ,  launchOptions ) ; 
7690      } 
77-     } 
78-     // Firebase Facebook authentication 
79-     if  ( typeof  ( FBSDKApplicationDelegate )  !==  "undefined" )  { 
80-       FBSDKApplicationDelegate . sharedInstance ( ) . applicationDidFinishLaunchingWithOptions ( application ,  launchOptions ) ; 
81-     } 
82-     return  true ; 
83-   } ; 
91+ 
92+       return  true ; 
93+     } ; 
94+   } 
8495
8596  // there's no notification event to hook into for this one, so using the appDelegate 
8697  if  ( typeof  ( FBSDKApplicationDelegate )  !==  "undefined"  ||  typeof  ( GIDSignIn )  !==  "undefined"  ||  typeof  ( FIRInvites )  !==  "undefined"  ||  typeof  ( FIRDynamicLink )  !==  "undefined" )  { 
0 commit comments