BKPasscodeViewController.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // BKPasscodeViewController.h
  3. // BKPasscodeViewDemo
  4. //
  5. // Created by Byungkook Jang on 2014. 4. 20..
  6. // Copyright (c) 2014년 Byungkook Jang. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "BKPasscodeInputView.h"
  10. #import "BKTouchIDSwitchView.h"
  11. #import "BKTouchIDManager.h"
  12. typedef enum : NSUInteger {
  13. BKPasscodeViewControllerNewPasscodeType,
  14. BKPasscodeViewControllerChangePasscodeType,
  15. BKPasscodeViewControllerCheckPasscodeType
  16. } BKPasscodeViewControllerType;
  17. @protocol BKPasscodeViewControllerDelegate;
  18. @interface BKPasscodeViewController : UIViewController <BKPasscodeInputViewDelegate, BKTouchIDSwitchViewDelegate>
  19. @property (nonatomic, weak) id<BKPasscodeViewControllerDelegate> delegate;
  20. @property (nonatomic) BKPasscodeViewControllerType type;
  21. @property (nonatomic) BKPasscodeInputViewPasscodeStyle passcodeStyle;
  22. @property (nonatomic) UIKeyboardType keyboardType;
  23. @property (nonatomic, strong, readonly) BKPasscodeInputView *passcodeInputView;
  24. @property (nonatomic, strong) BKTouchIDManager *touchIDManager;
  25. @property BOOL inputViewTitlePassword;
  26. /**
  27. * Customize passcode input view
  28. * You may override to customize passcode input view appearance.
  29. */
  30. - (void)customizePasscodeInputView:(BKPasscodeInputView *)aPasscodeInputView;
  31. /**
  32. * Instantiate passcode input view.
  33. * You may override to use custom passcode input view.
  34. */
  35. - (BKPasscodeInputView *)instantiatePasscodeInputView;
  36. /**
  37. * Prompts Touch ID view to scan fingerprint.
  38. */
  39. - (void)startTouchIDAuthenticationIfPossible;
  40. /**
  41. * Prompts Touch ID view to scan fingerprint.
  42. * If Touch ID is disabled or unavailable, value of 'prompted' will be NO.
  43. */
  44. - (void)startTouchIDAuthenticationIfPossible:(void(^)(BOOL prompted))aCompletionBlock;
  45. @end
  46. @protocol BKPasscodeViewControllerDelegate <NSObject>
  47. /**
  48. * Tells the delegate that passcode is created or authenticated successfully.
  49. */
  50. - (void)passcodeViewController:(BKPasscodeViewController *)aViewController didFinishWithPasscode:(NSString *)aPasscode;
  51. @optional
  52. /**
  53. * Tells the delegate that Touch ID error occured.
  54. */
  55. - (void)passcodeViewControllerDidFailTouchIDKeychainOperation:(BKPasscodeViewController *)aViewController;
  56. /**
  57. * Ask the delegate to verify that a passcode is correct. You must call the resultHandler with result.
  58. * You can check passcode asynchronously and show progress view (e.g. UIActivityIndicator) in the view controller if authentication takes too long.
  59. * You must call result handler in main thread.
  60. */
  61. - (void)passcodeViewController:(BKPasscodeViewController *)aViewController authenticatePasscode:(NSString *)aPasscode resultHandler:(void(^)(BOOL succeed))aResultHandler;
  62. /**
  63. * Tells the delegate that user entered incorrect passcode.
  64. * You should manage failed attempts yourself and it should be returned by -[BKPasscodeViewControllerDelegate passcodeViewControllerNumberOfFailedAttempts:] method.
  65. */
  66. - (void)passcodeViewControllerDidFailAttempt:(BKPasscodeViewController *)aViewController;
  67. /**
  68. * Ask the delegate that how many times incorrect passcode entered to display failed attempt count.
  69. */
  70. - (NSUInteger)passcodeViewControllerNumberOfFailedAttempts:(BKPasscodeViewController *)aViewController;
  71. /**
  72. * Ask the delegate that whether passcode view should lock or unlock.
  73. * If you return nil, passcode view will unlock otherwise it will lock until the date.
  74. */
  75. - (NSDate *)passcodeViewControllerLockUntilDate:(BKPasscodeViewController *)aViewController;
  76. @end