@@ -362,11 +362,13 @@ firebase.init = arg => {
362362 if ( typeof ( com . facebook ) !== "undefined" && typeof ( com . facebook . FacebookSdk ) !== "undefined" ) {
363363 com . facebook . FacebookSdk . sdkInitialize ( com . tns . NativeScriptApplication . getInstance ( ) ) ;
364364 fbCallbackManager = com . facebook . CallbackManager . Factory . create ( ) ;
365- appModule . android . on ( appModule . AndroidApplication . activityResultEvent , ( eventData : AndroidActivityResultEventData ) => {
365+ const callback = ( eventData : AndroidActivityResultEventData ) => {
366366 if ( eventData . requestCode !== GOOGLE_SIGNIN_INTENT_ID ) {
367+ appModule . android . off ( appModule . AndroidApplication . activityResultEvent , callback ) ;
367368 fbCallbackManager . onActivityResult ( eventData . requestCode , eventData . resultCode , eventData . intent ) ;
368369 }
369- } ) ;
370+ } ;
371+ appModule . android . on ( appModule . AndroidApplication . activityResultEvent , callback ) ;
370372 }
371373
372374 // Firebase AdMob
@@ -1272,8 +1274,9 @@ firebase.login = arg => {
12721274
12731275 appModule . android . currentContext . startActivityForResult ( signInIntent , GOOGLE_SIGNIN_INTENT_ID ) ;
12741276
1275- appModule . android . on ( appModule . AndroidApplication . activityResultEvent , ( eventData : AndroidActivityResultEventData ) => {
1277+ const callback = ( eventData : AndroidActivityResultEventData ) => {
12761278 if ( eventData . requestCode === GOOGLE_SIGNIN_INTENT_ID ) {
1279+ appModule . android . off ( appModule . AndroidApplication . activityResultEvent , callback ) ;
12771280 const googleSignInResult = com . google . android . gms . auth . api . Auth . GoogleSignInApi . getSignInResultFromIntent ( eventData . intent ) ;
12781281 const success = googleSignInResult . isSuccess ( ) ;
12791282 if ( success ) {
@@ -1299,7 +1302,8 @@ firebase.login = arg => {
12991302 reject ( "Has the SHA1 fingerprint been uploaded? Sign-in status: " + googleSignInResult . getStatus ( ) ) ;
13001303 }
13011304 }
1302- } ) ;
1305+ } ;
1306+ appModule . android . on ( appModule . AndroidApplication . activityResultEvent , callback ) ;
13031307
13041308 } else {
13051309 reject ( "Unsupported auth type: " + arg . type ) ;
@@ -2020,8 +2024,9 @@ firebase.invites.sendInvitation = arg => {
20202024
20212025 appModule . android . foregroundActivity . startActivityForResult ( firebaseInviteIntent , REQUEST_INVITE_INTENT_ID ) ;
20222026
2023- appModule . android . on ( appModule . AndroidApplication . activityResultEvent , ( eventData : AndroidActivityResultEventData ) => {
2027+ const callback = ( eventData : AndroidActivityResultEventData ) => {
20242028 if ( eventData . requestCode === REQUEST_INVITE_INTENT_ID ) {
2029+ appModule . android . off ( appModule . AndroidApplication . activityResultEvent , callback ) ;
20252030 if ( eventData . resultCode === android . app . Activity . RESULT_OK ) {
20262031 // Get the invitation IDs of all sent messages
20272032 const ids = com . google . android . gms . appinvite . AppInviteInvitation . getInvitationIds ( eventData . resultCode , eventData . intent ) ;
@@ -2043,7 +2048,8 @@ firebase.invites.sendInvitation = arg => {
20432048 }
20442049 }
20452050 }
2046- } ) ;
2051+ } ;
2052+ appModule . android . on ( appModule . AndroidApplication . activityResultEvent , callback ) ;
20472053
20482054 } catch ( ex ) {
20492055 console . log ( "Error in firebase.sendInvitation: " + ex ) ;
0 commit comments