Skip to content

Commit

Permalink
Fix authStateChanged after app is reloaded (fixes #1677)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghsdh3409 committed Nov 20, 2018
1 parent 9486cdc commit 1b5a964
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ios/RNFirebase/auth/RNFirebaseAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ - (void)dealloc {
}
}

- (void)invalidate {
// dealloc sometimes is not called when app is reloaded.

for(NSString* key in authStateHandlers) {
FIRApp *firApp = [RNFirebaseUtil getApp:key];
[[FIRAuth authWithApp:firApp] removeAuthStateDidChangeListener:[authStateHandlers valueForKey:key]];
[authStateHandlers removeObjectForKey:key];
}

for(NSString* key in idTokenHandlers) {
FIRApp *firApp = [RNFirebaseUtil getApp:key];
[[FIRAuth authWithApp:firApp] removeIDTokenDidChangeListener:[idTokenHandlers valueForKey:key]];
[idTokenHandlers removeObjectForKey:key];
}
}

/**
* addAuthStateListener
*
Expand Down

0 comments on commit 1b5a964

Please sign in to comment.