mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Fixed self.validated not always being set to NO if restrictionEnforcementFrequency is set to BITAuthenticatorAppRestrictionEnforcementOnAppActive
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user