Skip to content

Commit

Permalink
New TokenInvalid Handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jleandroperez committed Aug 14, 2021
1 parent 966f2fd commit 0cbc925
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Simperium/Simperium.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ - (void)setupNotifications {
#endif

NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(authenticationDidFail) name:SPAuthenticationDidFail object:nil];
[nc addObserver:self selector:@selector(handleNetworkChange:) name:kSPReachabilityChangedNotification object:nil];
[nc addObserver:self selector:@selector(handleTokenInvalid:) name:SPAuthenticationTokenInvalid object:nil];
[nc addObserver:self selector:@selector(handleNetworkChange:) name:kSPReachabilityChangedNotification object:nil];
}

- (void)setupCoreDataWithModel:(NSManagedObjectModel *)model
Expand Down Expand Up @@ -242,6 +242,14 @@ - (void)handleNetworkChange:(NSNotification *)notification {
}
}

- (void)handleTokenInvalid:(NSNotification *)notification {
// Clear the token and user
[self resetAuthToken];

// Notify Delegate / Trigger reauth flow
[self authenticationDidFail];
}

- (void)setNetworkEnabled:(BOOL)enabled {
if (self.networkEnabled == enabled) {
return;
Expand Down

0 comments on commit 0cbc925

Please sign in to comment.