Fixed self.validated not always being set to NO if restrictionEnforcementFrequency is set to BITAuthenticatorAppRestrictionEnforcementOnAppActive

This commit is contained in:
Andreas Linde
2013-12-04 14:08:08 +01:00
parent 785f654060
commit 6d6012b0f6
2 changed files with 11 additions and 14 deletions

View File

@@ -48,7 +48,7 @@ static NSString* const kBITAuthenticatorAuthTokenTypeKey = @"BITAuthenticatorAut
@implementation BITAuthenticator {
id _appDidBecomeActiveObserver;
id _appWillResignActiveObserver;
id _appDidEnterBackgroundOberser;
UIViewController *_authenticationController;
BOOL _isSetup;
@@ -651,13 +651,13 @@ static NSString* const kBITAuthenticatorAuthTokenTypeKey = @"BITAuthenticatorAut
[strongSelf applicationDidBecomeActive:note];
}];
}
if(nil == _appWillResignActiveObserver) {
_appWillResignActiveObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillResignActiveNotification
if(nil == _appDidEnterBackgroundOberser) {
_appDidEnterBackgroundOberser = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidEnterBackgroundNotification
object:nil
queue:NSOperationQueue.mainQueue
usingBlock:^(NSNotification *note) {
typeof(self) strongSelf = weakSelf;
[strongSelf applicationWillResignActive:note];
[strongSelf applicationDidEnterBackground:note];
}];
}
}
@@ -667,9 +667,9 @@ static NSString* const kBITAuthenticatorAuthTokenTypeKey = @"BITAuthenticatorAut
[[NSNotificationCenter defaultCenter] removeObserver:_appDidBecomeActiveObserver];
_appDidBecomeActiveObserver = nil;
}
if(_appWillResignActiveObserver) {
[[NSNotificationCenter defaultCenter] removeObserver:_appWillResignActiveObserver];
_appWillResignActiveObserver = nil;
if(_appDidEnterBackgroundOberser) {
[[NSNotificationCenter defaultCenter] removeObserver:_appDidEnterBackgroundOberser];
_appDidEnterBackgroundOberser = nil;
}
}
@@ -755,11 +755,8 @@ static NSString* const kBITAuthenticatorAuthTokenTypeKey = @"BITAuthenticatorAut
[self authenticate];
}
- (void)applicationWillResignActive:(NSNotification *)note {
//only reset if app is really going into the background, e.g not when pulling down
//the notification center
if(BITAuthenticatorAppRestrictionEnforcementOnAppActive == self.restrictionEnforcementFrequency &&
[[UIApplication sharedApplication] applicationState] == UIApplicationStateBackground) {
- (void)applicationDidEnterBackground:(NSNotification *)note {
if(BITAuthenticatorAppRestrictionEnforcementOnAppActive == self.restrictionEnforcementFrequency) {
self.validated = NO;
}
}

View File

@@ -60,11 +60,11 @@
@property (nonatomic, copy, readonly) NSString *installationIdentifier;
/**
* method registered as observer for applicationWillBecomeInactive events
* method registered as observer for applicationDidEnterBackground events
*
* @param note NSNotification
*/
- (void) applicationWillResignActive:(NSNotification*) note;
- (void) applicationDidEnterBackground:(NSNotification*) note;
/**
* method registered as observer for applicationsDidBecomeActive events