BKPasscodeViewController.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. //
  2. // BKPasscodeViewController.m
  3. // BKPasscodeViewDemo
  4. //
  5. // Created by Byungkook Jang on 2014. 4. 20..
  6. // Copyright (c) 2014년 Byungkook Jang. All rights reserved.
  7. //
  8. #import "BKPasscodeViewController.h"
  9. #import "BKShiftingView.h"
  10. #import "AFViewShaker.h"
  11. #import "BKPasscodeUtils.h"
  12. typedef enum : NSUInteger {
  13. BKPasscodeViewControllerStateUnknown,
  14. BKPasscodeViewControllerStateCheckPassword,
  15. BKPasscodeViewControllerStateInputPassword,
  16. BKPasscodeViewControllerStateReinputPassword
  17. } BKPasscodeViewControllerState;
  18. #define kBKPasscodeOneMinuteInSeconds (60)
  19. #define kBKPasscodeDefaultKeyboardHeight (216)
  20. @interface BKPasscodeViewController ()
  21. @property (nonatomic, strong) BKShiftingView *shiftingView;
  22. @property (nonatomic) BKPasscodeViewControllerState currentState;
  23. @property (nonatomic, strong) NSString *oldPasscode;
  24. @property (nonatomic, strong) NSString *theNewPasscode;
  25. @property (nonatomic, strong) NSTimer *lockStateUpdateTimer;
  26. @property (nonatomic) CGFloat keyboardHeight;
  27. @property (nonatomic, strong) AFViewShaker *viewShaker;
  28. @property (nonatomic) BOOL promptingTouchID;
  29. @end
  30. @implementation BKPasscodeViewController
  31. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  32. {
  33. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  34. if (self) {
  35. // init state
  36. _type = BKPasscodeViewControllerNewPasscodeType;
  37. _currentState = BKPasscodeViewControllerStateInputPassword;
  38. // create shifting view
  39. self.shiftingView = [[BKShiftingView alloc] init];
  40. self.shiftingView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  41. self.shiftingView.currentView = [self instantiatePasscodeInputView];
  42. // keyboard notifications
  43. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveKeyboardWillShowHideNotification:) name:UIKeyboardWillShowNotification object:nil];
  44. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveKeyboardWillShowHideNotification:) name:UIKeyboardWillHideNotification object:nil];
  45. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveApplicationWillEnterForegroundNotification:)
  46. name:UIApplicationWillEnterForegroundNotification
  47. object:nil];
  48. self.keyboardHeight = kBKPasscodeDefaultKeyboardHeight; // sometimes keyboard notification is not posted at all. so setting default value.
  49. }
  50. return self;
  51. }
  52. - (void)dealloc
  53. {
  54. [self.lockStateUpdateTimer invalidate];
  55. self.lockStateUpdateTimer = nil;
  56. [[NSNotificationCenter defaultCenter] removeObserver:self];
  57. }
  58. - (void)setType:(BKPasscodeViewControllerType)type
  59. {
  60. if (_type == type) {
  61. return;
  62. }
  63. _type = type;
  64. switch (type) {
  65. case BKPasscodeViewControllerNewPasscodeType:
  66. self.currentState = BKPasscodeViewControllerStateInputPassword;
  67. break;
  68. default:
  69. self.currentState = BKPasscodeViewControllerStateCheckPassword;
  70. break;
  71. }
  72. }
  73. - (BKPasscodeInputView *)passcodeInputView
  74. {
  75. if (NO == [self.shiftingView.currentView isKindOfClass:[BKPasscodeInputView class]]) {
  76. return nil;
  77. }
  78. return (BKPasscodeInputView *)self.shiftingView.currentView;
  79. }
  80. - (BKPasscodeInputView *)instantiatePasscodeInputView
  81. {
  82. BKPasscodeInputView *view = [[BKPasscodeInputView alloc] init];
  83. view.delegate = self;
  84. view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  85. return view;
  86. }
  87. - (void)customizePasscodeInputView:(BKPasscodeInputView *)aPasscodeInputView
  88. {
  89. }
  90. - (void)viewDidLoad
  91. {
  92. [super viewDidLoad];
  93. [self.view setBackgroundColor:[UIColor colorWithRed:0.94 green:0.94 blue:0.96 alpha:1]];
  94. [self updatePasscodeInputViewTitle:self.passcodeInputView];
  95. [self customizePasscodeInputView:self.passcodeInputView];
  96. [self.view addSubview:self.shiftingView];
  97. [self lockIfNeeded];
  98. }
  99. - (void)viewWillAppear:(BOOL)animated
  100. {
  101. [super viewWillAppear:animated];
  102. if (self.passcodeInputView.isEnabled) {
  103. //TWS
  104. [self performSelector:@selector(startTouchIDAuthenticationIfPossible) withObject:nil afterDelay:0.2];
  105. }
  106. [self.passcodeInputView becomeFirstResponder];
  107. }
  108. - (void)viewWillDisappear:(BOOL)animated
  109. {
  110. [super viewWillDisappear:animated];
  111. [self.view endEditing:YES];
  112. }
  113. - (void)viewDidLayoutSubviews
  114. {
  115. [super viewDidLayoutSubviews];
  116. CGRect frame = self.view.bounds;
  117. CGFloat topBarOffset = 0;
  118. if ([self respondsToSelector:@selector(topLayoutGuide)]) {
  119. topBarOffset = [self.topLayoutGuide length];
  120. }
  121. frame.origin.y += topBarOffset;
  122. frame.size.height -= (topBarOffset + self.keyboardHeight);
  123. self.shiftingView.frame = frame;
  124. }
  125. #pragma mark - Public methods
  126. - (void)setPasscodeStyle:(BKPasscodeInputViewPasscodeStyle)passcodeStyle
  127. {
  128. self.passcodeInputView.passcodeStyle = passcodeStyle;
  129. }
  130. - (BKPasscodeInputViewPasscodeStyle)passcodeStyle
  131. {
  132. return self.passcodeInputView.passcodeStyle;
  133. }
  134. - (void)setKeyboardType:(UIKeyboardType)keyboardType
  135. {
  136. self.passcodeInputView.keyboardType = keyboardType;
  137. }
  138. - (UIKeyboardType)keyboardType
  139. {
  140. return self.passcodeInputView.keyboardType;
  141. }
  142. - (void)showLockMessageWithLockUntilDate:(NSDate *)lockUntil
  143. {
  144. NSTimeInterval timeInterval = [lockUntil timeIntervalSinceNow];
  145. NSUInteger minutes = ceilf(timeInterval / 60.0f);
  146. BKPasscodeInputView *inputView = self.passcodeInputView;
  147. inputView.enabled = NO;
  148. if (minutes == 1) {
  149. inputView.title = NSLocalizedStringFromTable(@"Try again in 1 minute", @"BKPasscodeView", @"1분 후에 다시 시도");
  150. } else {
  151. inputView.title = [NSString stringWithFormat:NSLocalizedStringFromTable(@"Try again in %d minutes", @"BKPasscodeView", @"%d분 후에 다시 시도"), minutes];
  152. }
  153. NSUInteger numberOfFailedAttempts = [self.delegate passcodeViewControllerNumberOfFailedAttempts:self];
  154. [self showFailedAttemptsCount:numberOfFailedAttempts inputView:inputView];
  155. if (self.lockStateUpdateTimer == nil) {
  156. NSTimeInterval delay = timeInterval + kBKPasscodeOneMinuteInSeconds - (kBKPasscodeOneMinuteInSeconds * (NSTimeInterval)minutes);
  157. self.lockStateUpdateTimer = [[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:delay]
  158. interval:60.f
  159. target:self
  160. selector:@selector(lockStateUpdateTimerFired:)
  161. userInfo:nil
  162. repeats:YES];
  163. [[NSRunLoop currentRunLoop] addTimer:self.lockStateUpdateTimer forMode:NSDefaultRunLoopMode];
  164. }
  165. }
  166. - (BOOL)lockIfNeeded
  167. {
  168. if (self.currentState != BKPasscodeViewControllerStateCheckPassword) {
  169. return NO;
  170. }
  171. if (NO == [self.delegate respondsToSelector:@selector(passcodeViewControllerLockUntilDate:)]) {
  172. return NO;
  173. }
  174. NSDate *lockUntil = [self.delegate passcodeViewControllerLockUntilDate:self];
  175. if (lockUntil == nil || [lockUntil timeIntervalSinceNow] < 0) {
  176. return NO;
  177. }
  178. [self showLockMessageWithLockUntilDate:lockUntil];
  179. return YES;
  180. }
  181. - (void)updateLockMessageOrUnlockIfNeeded
  182. {
  183. if (self.currentState != BKPasscodeViewControllerStateCheckPassword) {
  184. return;
  185. }
  186. if (NO == [self.delegate respondsToSelector:@selector(passcodeViewControllerLockUntilDate:)]) {
  187. return;
  188. }
  189. BKPasscodeInputView *inputView = self.passcodeInputView;
  190. NSDate *lockUntil = [self.delegate passcodeViewControllerLockUntilDate:self];
  191. if (lockUntil == nil || [lockUntil timeIntervalSinceNow] < 0) {
  192. // invalidate timer
  193. [self.lockStateUpdateTimer invalidate];
  194. self.lockStateUpdateTimer = nil;
  195. [self updatePasscodeInputViewTitle:inputView];
  196. inputView.enabled = YES;
  197. } else {
  198. [self showLockMessageWithLockUntilDate:lockUntil];
  199. }
  200. }
  201. - (void)lockStateUpdateTimerFired:(NSTimer *)timer
  202. {
  203. [self updateLockMessageOrUnlockIfNeeded];
  204. }
  205. - (void)startTouchIDAuthenticationIfPossible
  206. {
  207. [self startTouchIDAuthenticationIfPossible:nil];
  208. }
  209. - (void)startTouchIDAuthenticationIfPossible:(void (^)(BOOL))aCompletionBlock
  210. {
  211. if (NO == [self canAuthenticateWithTouchID]) {
  212. if (aCompletionBlock) {
  213. aCompletionBlock(NO);
  214. }
  215. return;
  216. }
  217. self.promptingTouchID = YES;
  218. [self.touchIDManager loadPasscodeWithCompletionBlock:^(NSString *passcode) {
  219. self.promptingTouchID = NO;
  220. if (passcode) {
  221. self.passcodeInputView.passcode = passcode;
  222. [self passcodeInputViewDidFinish:self.passcodeInputView];
  223. }
  224. if (aCompletionBlock) {
  225. aCompletionBlock(YES);
  226. }
  227. }];
  228. }
  229. #pragma mark - Private methods
  230. - (void)updatePasscodeInputViewTitle:(BKPasscodeInputView *)passcodeInputView
  231. {
  232. switch (self.currentState) {
  233. case BKPasscodeViewControllerStateCheckPassword:
  234. if (self.type == BKPasscodeViewControllerChangePasscodeType) {
  235. if (self.inputViewTitlePassword) passcodeInputView.title = NSLocalizedStringFromTable(@"Enter your old password", @"BKPasscodeView", @"Enter your old password");
  236. else passcodeInputView.title = NSLocalizedStringFromTable(@"Enter your old passcode", @"BKPasscodeView", @"기존 암호 입력");
  237. } else {
  238. if (self.inputViewTitlePassword) passcodeInputView.title = NSLocalizedStringFromTable(@"Enter your password", @"BKPasscodeView", @"Enter your password");
  239. else passcodeInputView.title = NSLocalizedStringFromTable(@"Enter your passcode", @"BKPasscodeView", @"암호 입력");
  240. }
  241. break;
  242. case BKPasscodeViewControllerStateInputPassword:
  243. if (self.type == BKPasscodeViewControllerChangePasscodeType) {
  244. if (self.inputViewTitlePassword) passcodeInputView.title = NSLocalizedStringFromTable(@"Enter your new password", @"BKPasscodeView", @"Enter your new password");
  245. else passcodeInputView.title = NSLocalizedStringFromTable(@"Enter your new passcode", @"BKPasscodeView", @"새로운 암호 입력");
  246. } else {
  247. if (self.inputViewTitlePassword) passcodeInputView.title = NSLocalizedStringFromTable(@"Enter a password", @"BKPasscodeView", @"Enter a password");
  248. else passcodeInputView.title = NSLocalizedStringFromTable(@"Enter a passcode", @"BKPasscodeView", @"암호 입력");
  249. }
  250. break;
  251. case BKPasscodeViewControllerStateReinputPassword:
  252. if (self.inputViewTitlePassword) passcodeInputView.title = NSLocalizedStringFromTable(@"Re-enter your password", @"BKPasscodeView", @"Re-enter your password");
  253. else passcodeInputView.title = NSLocalizedStringFromTable(@"Re-enter your passcode", @"BKPasscodeView", @"암호 재입력");
  254. break;
  255. default:
  256. break;
  257. }
  258. }
  259. - (void)showFailedAttemptsCount:(NSUInteger)failCount inputView:(BKPasscodeInputView *)aInputView
  260. {
  261. if (failCount == 0) {
  262. if (self.inputViewTitlePassword) aInputView.errorMessage = NSLocalizedStringFromTable(@"Invalid Password", @"BKPasscodeView", @"Invalid Password");
  263. else aInputView.errorMessage = NSLocalizedStringFromTable(@"Invalid Passcode", @"BKPasscodeView", @"잘못된 암호");
  264. } else if (failCount == 1) {
  265. if (self.inputViewTitlePassword) aInputView.errorMessage = NSLocalizedStringFromTable(@"1 Failed Password Attempt", @"BKPasscodeView", @"1 Failed Password Attempt");
  266. else aInputView.errorMessage = NSLocalizedStringFromTable(@"1 Failed Passcode Attempt", @"BKPasscodeView", @"1번의 암호 입력 시도 실패");
  267. } else {
  268. if (self.inputViewTitlePassword) aInputView.errorMessage = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%d Failed Password Attempts", @"BKPasscodeView", @"%d Failed Password Attempts"), failCount];
  269. else aInputView.errorMessage = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%d Failed Passcode Attempts", @"BKPasscodeView", @"%d번의 암호 입력 시도 실패"), failCount];
  270. }
  271. }
  272. - (void)showTouchIDSwitchView
  273. {
  274. BKTouchIDSwitchView *view = [[BKTouchIDSwitchView alloc] init];
  275. view.delegate = self;
  276. view.touchIDSwitch.on = self.touchIDManager.isTouchIDEnabled;
  277. [self.shiftingView showView:view withDirection:BKShiftingDirectionForward];
  278. }
  279. - (BOOL)canAuthenticateWithTouchID
  280. {
  281. if (NO == [BKTouchIDManager canUseTouchID]) {
  282. return NO;
  283. }
  284. if (self.type != BKPasscodeViewControllerCheckPasscodeType) {
  285. return NO;
  286. }
  287. if (nil == self.touchIDManager || NO == self.touchIDManager.isTouchIDEnabled) {
  288. return NO;
  289. }
  290. if (self.promptingTouchID) {
  291. return NO;
  292. }
  293. #ifndef SHARE_IN
  294. if ([UIApplication sharedApplication].applicationState == UIApplicationStateInactive) {
  295. return NO;
  296. }
  297. #endif
  298. return YES;
  299. }
  300. #pragma mark - BKPasscodeInputViewDelegate
  301. - (void)passcodeInputViewDidFinish:(BKPasscodeInputView *)aInputView
  302. {
  303. NSString *passcode = aInputView.passcode;
  304. switch (self.currentState) {
  305. case BKPasscodeViewControllerStateCheckPassword:
  306. {
  307. NSAssert([self.delegate respondsToSelector:@selector(passcodeViewController:authenticatePasscode:resultHandler:)],
  308. @"delegate must implement passcodeViewController:authenticatePasscode:resultHandler:");
  309. [self.delegate passcodeViewController:self authenticatePasscode:passcode resultHandler:^(BOOL succeed) {
  310. NSAssert([NSThread isMainThread], @"you must invoke result handler in main thread.");
  311. if (succeed) {
  312. if (self.type == BKPasscodeViewControllerChangePasscodeType) {
  313. self.oldPasscode = passcode;
  314. self.currentState = BKPasscodeViewControllerStateInputPassword;
  315. BKPasscodeInputView *newPasscodeInputView = [self.passcodeInputView copy];
  316. [self customizePasscodeInputView:newPasscodeInputView];
  317. [self updatePasscodeInputViewTitle:newPasscodeInputView];
  318. [self.shiftingView showView:newPasscodeInputView withDirection:BKShiftingDirectionForward];
  319. [self.passcodeInputView becomeFirstResponder];
  320. } else {
  321. [self.delegate passcodeViewController:self didFinishWithPasscode:passcode];
  322. }
  323. } else {
  324. if ([self.delegate respondsToSelector:@selector(passcodeViewControllerDidFailAttempt:)]) {
  325. [self.delegate passcodeViewControllerDidFailAttempt:self];
  326. }
  327. NSUInteger failCount = 0;
  328. if ([self.delegate respondsToSelector:@selector(passcodeViewControllerNumberOfFailedAttempts:)]) {
  329. failCount = [self.delegate passcodeViewControllerNumberOfFailedAttempts:self];
  330. }
  331. [self showFailedAttemptsCount:failCount inputView:aInputView];
  332. // reset entered passcode
  333. aInputView.passcode = nil;
  334. // shake
  335. self.viewShaker = [[AFViewShaker alloc] initWithView:aInputView.passcodeField];
  336. [self.viewShaker shakeWithDuration:0.5f completion:nil];
  337. // lock if needed
  338. if ([self.delegate respondsToSelector:@selector(passcodeViewControllerLockUntilDate:)]) {
  339. NSDate *lockUntilDate = [self.delegate passcodeViewControllerLockUntilDate:self];
  340. if (lockUntilDate != nil) {
  341. [self showLockMessageWithLockUntilDate:lockUntilDate];
  342. }
  343. }
  344. }
  345. }];
  346. break;
  347. }
  348. case BKPasscodeViewControllerStateInputPassword:
  349. {
  350. if (self.type == BKPasscodeViewControllerChangePasscodeType && [self.oldPasscode isEqualToString:passcode]) {
  351. aInputView.passcode = nil;
  352. if (self.inputViewTitlePassword) aInputView.message = NSLocalizedStringFromTable(@"Enter a different password. Cannot re-use the same password.", @"BKPasscodeView", @"Enter a different password. Cannot re-use the same password.");
  353. else aInputView.message = NSLocalizedStringFromTable(@"Enter a different passcode. Cannot re-use the same passcode.", @"BKPasscodeView", @"다른 암호를 입력하십시오. 동일한 암호를 다시 사용할 수 없습니다.");
  354. } else {
  355. self.theNewPasscode = passcode;
  356. self.currentState = BKPasscodeViewControllerStateReinputPassword;
  357. BKPasscodeInputView *newPasscodeInputView = [self.passcodeInputView copy];
  358. [self customizePasscodeInputView:newPasscodeInputView];
  359. [self updatePasscodeInputViewTitle:newPasscodeInputView];
  360. [self.shiftingView showView:newPasscodeInputView withDirection:BKShiftingDirectionForward];
  361. [self.passcodeInputView becomeFirstResponder];
  362. }
  363. break;
  364. }
  365. case BKPasscodeViewControllerStateReinputPassword:
  366. {
  367. if ([passcode isEqualToString:self.theNewPasscode]) {
  368. if (self.touchIDManager && [BKTouchIDManager canUseTouchID]) {
  369. [self showTouchIDSwitchView];
  370. } else {
  371. [self.delegate passcodeViewController:self didFinishWithPasscode:passcode];
  372. }
  373. } else {
  374. self.currentState = BKPasscodeViewControllerStateInputPassword;
  375. BKPasscodeInputView *newPasscodeInputView = [self.passcodeInputView copy];
  376. [self customizePasscodeInputView:newPasscodeInputView];
  377. [self updatePasscodeInputViewTitle:newPasscodeInputView];
  378. if (self.inputViewTitlePassword) newPasscodeInputView.message = NSLocalizedStringFromTable(@"Password did not match.\nTry again.", @"BKPasscodeView", @"Password did not match.\nTry again.");
  379. else newPasscodeInputView.message = NSLocalizedStringFromTable(@"Passcodes did not match.\nTry again.", @"BKPasscodeView", @"암호가 일치하지 않습니다.\n다시 시도하십시오.");
  380. [self.shiftingView showView:newPasscodeInputView withDirection:BKShiftingDirectionBackward];
  381. [self.passcodeInputView becomeFirstResponder];
  382. }
  383. break;
  384. }
  385. default:
  386. break;
  387. }
  388. }
  389. #pragma mark - BKTouchIDSwitchViewDelegate
  390. - (void)touchIDSwitchViewDidPressDoneButton:(BKTouchIDSwitchView *)view
  391. {
  392. BOOL enabled = view.touchIDSwitch.isOn;
  393. if (enabled) {
  394. [self.touchIDManager savePasscode:self.theNewPasscode completionBlock:^(BOOL success) {
  395. if (success) {
  396. [self.delegate passcodeViewController:self didFinishWithPasscode:self.theNewPasscode];
  397. } else {
  398. if ([self.delegate respondsToSelector:@selector(passcodeViewControllerDidFailTouchIDKeychainOperation:)]) {
  399. [self.delegate passcodeViewControllerDidFailTouchIDKeychainOperation:self];
  400. }
  401. }
  402. }];
  403. } else {
  404. [self.touchIDManager deletePasscodeWithCompletionBlock:^(BOOL success) {
  405. if (success) {
  406. [self.delegate passcodeViewController:self didFinishWithPasscode:self.theNewPasscode];
  407. } else {
  408. if ([self.delegate respondsToSelector:@selector(passcodeViewControllerDidFailTouchIDKeychainOperation:)]) {
  409. [self.delegate passcodeViewControllerDidFailTouchIDKeychainOperation:self];
  410. }
  411. }
  412. }];
  413. }
  414. }
  415. #pragma mark - Notifications
  416. - (void)didReceiveKeyboardWillShowHideNotification:(NSNotification *)notification
  417. {
  418. CGRect keyboardRect = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
  419. /*
  420. #ifdef SHARE_IN
  421. self.keyboardHeight = CGRectGetHeight(keyboardRect);
  422. #else
  423. UIInterfaceOrientation statusBarOrientation = [[UIApplication sharedApplication] statusBarOrientation];
  424. self.keyboardHeight = UIInterfaceOrientationIsPortrait(statusBarOrientation) ? CGRectGetWidth(keyboardRect) : CGRectGetHeight(keyboardRect);
  425. #endif
  426. */
  427. self.keyboardHeight = CGRectGetHeight(keyboardRect);
  428. [self.view setNeedsLayout];
  429. }
  430. - (void)didReceiveApplicationWillEnterForegroundNotification:(NSNotification *)notification
  431. {
  432. [self startTouchIDAuthenticationIfPossible];
  433. }
  434. @end