-2
A
回答
-1
如果您想在越獄設備上使用私人BiometricKit框架,我無法真正幫助您......
如果您只想利用TouchID功能,您只需要使用公共LocalAuthentication框架。
下面是一個Objective-C中一個非常基本實現假裝MyViewController
的UIViewController
子類(您最終可能要移動的邏輯離開那裏):
#import "MyViewController.h"
@import LocalAuthentication;
@interface MyViewController()
@property (nonatomic, strong) LAContext *localAuthContext;
@end
@implementation MyViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self authenticateWithTouchID]; // Call this whenever TouchID authentication is required.
}
#pragma mark - TouchID Authentication
- (void)authenticateWithTouchID {
NSError *evaluationError;
if (![self.localAuthContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&evaluationError]) {
// TODO: Handle error case. (device with no TouchID capability)
NSLog(@"%@", evaluationError.localizedDescription);
} else {
[self.localAuthContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:@"Authenticate using Touch ID"
reply:^(BOOL success, NSError *error) {
if (!success) {
// TODO: Handle error case. (failed TouchID authentication)
NSLog(@"%@", error.localizedDescription);
} else {
// TODO: Handle success case.
NSLog(@"TouchID authentication successful.");
}
}];
}
}
#pragma mark - Lazy Instantiation
- (LAContext *)localAuthContext
{
if (!_localAuthContext) {
_localAuthContext = [[LAContext alloc] init];
_localAuthContext.localizedFallbackTitle = @""; // Hides the "Enter Password" button. Comment out to allow the user to enter his device passcode as a fallback option.
}
return _localAuthContext;
}
@end
首先確保你有一個指紋設置在您的設備上(設置>觸摸ID &密碼>指紋部分)。
相關問題
- 1. 爲UWP應用程序指定啓動監視器
- 2. 如何在PHP中使用監視器?
- 3. 如何在ios中使用Mediaplayer框架播放視頻?
- 4. Opennms:如何啓用「Not Monitored」監視器
- 5. 如何在iOS 10中的viewDidAppear之前獲得正確的視圖框架?
- 6. 使用測試框架時如何啓動節點服務器?
- 7. 監視框架需要
- 8. Shell腳本:啓動監視器任務
- 9. Android設備監視器無法啓動
- 10. 從主java程序啓動監視器
- 11. 如何在機器人框架中執行指數動作
- 12. 在系統中監視進程啓動
- 13. 如何在iOS 10中使用TouchID
- 14. 如何在iOS 10中使用openURL?
- 15. 像iOS監視器一樣用於調試的Android監視器?
- 16. 使用Application Insights監視ASP.NET應用程序中的實體框架性能狀態監視器
- 17. 如何爲iOS 10啓用通知?
- 18. 如何在Excel中使用VBA在指定的監視器上打開IE?
- 19. 如何使用指紋傳感器在Android中驗證用戶?
- 20. 如何在onResume活動中重新啓用onClick監聽器
- 21. 監視Outlook啓動/關閉
- 22. python中的多服務器監視器/自動重啓器
- 23. 如何使用xcodebuild構建iOS框架?
- 24. 如何在ios中的一個小框架中顯示視頻
- 25. 在erlang/OTP中,如何啓動appmon來監視現有節點?
- 26. 如何在iOS中使用動畫顯示容器視圖?
- 27. 讓鎖屏的指紋傳感器在後臺監聽指紋Android
- 28. 在iOS 8框架中使用類別
- 29. 在ios編程中使用three20框架
- 30. 如何在swift iOS中使用Objective C靜態框架swift cocoa框架