@@ -101,8 +101,6 @@ firebase.addAppDelegateMethods = function(appDelegate) {
101101 addBackgroundRemoteNotificationHandler ( appDelegate ) ;
102102} ;
103103
104- addBackgroundRemoteNotificationHandler ( getAppDelegate ( ) ) ;
105-
106104firebase . addOnMessageReceivedCallback = function ( callback ) {
107105 return new Promise ( function ( resolve , reject ) {
108106 try {
@@ -225,7 +223,7 @@ firebase._registerForRemoteNotifications = function () {
225223 }
226224 if ( firebase . _registerForRemoteNotificationsRanThisSession ) {
227225 // ignore
228- return ;
226+ // return;
229227 }
230228 firebase . _registerForRemoteNotificationsRanThisSession = true ;
231229
@@ -289,6 +287,29 @@ firebase._registerForRemoteNotifications = function () {
289287 }
290288} ;
291289
290+ function getAppDelegate ( ) {
291+ // Play nice with other plugins by not completely ignoring anything already added to the appdelegate
292+ if ( application . ios . delegate === undefined ) {
293+ var __extends = this . __extends || function ( d , b ) {
294+ for ( var p in b ) if ( b . hasOwnProperty ( p ) ) d [ p ] = b [ p ] ;
295+ function __ ( ) { this . constructor = d ; }
296+ __ . prototype = b . prototype ;
297+ d . prototype = new __ ( ) ;
298+ } ;
299+
300+ var appDelegate = ( function ( _super ) {
301+ __extends ( appDelegate , _super ) ;
302+ function appDelegate ( ) {
303+ _super . apply ( this , arguments ) ;
304+ }
305+ appDelegate . ObjCProtocols = [ UIApplicationDelegate ] ;
306+ return appDelegate ;
307+ } ) ( UIResponder ) ;
308+ application . ios . delegate = appDelegate ;
309+ }
310+ return application . ios . delegate ;
311+ }
312+
292313// rather than hijacking the appDelegate for these we'll be a good citizen and listen to the notifications
293314function prepAppDelegate ( ) {
294315 if ( typeof ( FIRMessaging ) !== "undefined" ) {
@@ -328,29 +349,7 @@ function prepAppDelegate() {
328349 firebase . addAppDelegateMethods ( getAppDelegate ( ) ) ;
329350}
330351
331- function getAppDelegate ( ) {
332- // Play nice with other plugins by not completely ignoring anything already added to the appdelegate
333- if ( application . ios . delegate === undefined ) {
334- var __extends = this . __extends || function ( d , b ) {
335- for ( var p in b ) if ( b . hasOwnProperty ( p ) ) d [ p ] = b [ p ] ;
336- function __ ( ) { this . constructor = d ; }
337- __ . prototype = b . prototype ;
338- d . prototype = new __ ( ) ;
339- } ;
340-
341- var appDelegate = ( function ( _super ) {
342- __extends ( appDelegate , _super ) ;
343- function appDelegate ( ) {
344- _super . apply ( this , arguments ) ;
345- }
346- firebase . addAppDelegateMethods ( appDelegate ) ;
347- appDelegate . ObjCProtocols = [ UIApplicationDelegate ] ;
348- return appDelegate ;
349- } ) ( UIResponder ) ;
350- application . ios . delegate = appDelegate ;
351- }
352- return application . ios . delegate ;
353- }
352+ prepAppDelegate ( ) ;
354353
355354firebase . toJsObject = function ( objCObj ) {
356355 if ( objCObj === null || typeof objCObj != "object" ) {
@@ -423,8 +422,6 @@ firebase.init = function (arg) {
423422 function runInit ( ) {
424423 arg = arg || { } ;
425424
426- prepAppDelegate ( ) ;
427-
428425 // this requires you to download GoogleService-Info.plist and
429426 // it to app/App_Resources/iOS/, see https://firebase.google.com/support/guides/firebase-ios
430427 FIRApp . configure ( ) ;
@@ -496,9 +493,6 @@ firebase.init = function (arg) {
496493 resolve ( firebase . instance ) ;
497494 }
498495
499- // wrapped in a timeout to play nice with nativescript-angular's appdelegate handling,
500- // but reverted because of #272
501- // setTimeout(runInit, 0);
502496 runInit ( ) ;
503497 } catch ( ex ) {
504498 console . log ( "Error in firebase.init: " + ex ) ;
0 commit comments