Skip to content

Commit

Permalink
Fix authStateChanged after app is reloaded (Fixed invertase#1677)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghsdh3409 committed Nov 20, 2018
1 parent 9486cdc commit 65db5cf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions ios/RNFirebase/auth/RNFirebaseAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#import <Firebase.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>
#import <React/RCTInvalidating.h>

@interface RNFirebaseAuth : RCTEventEmitter <RCTBridgeModule> {};
@end
Expand Down
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 65db5cf

Please sign in to comment.