我正在创建一个应用程序,用户可以存储其他人的信息,我想允许用户使用密码或Touch ID保护我的应用程序中存储的信息(如果他们的设备支持它).
由于Apple的文档,我已经有了Touch ID部分工作,但我仍然坚持如何实现密码锁.我是否必须为该密码输入创建另一个视图控制器?如何确保我的应用无法访问用户密码(如果应用被黑客攻击或在越狱设备上运行)?Apple是否为此目的提供框架或库?
有人能指出我可以使用的一些源代码或文档吗?
我正在使用触摸ID登录的应用程序.它应该仅在首次启动时询问触摸ID(即,当应用程序从后台输入前景时,我不要求触摸ID身份验证).以下是我展示touchID的方法:
AppDelegate.swift:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let loginViewController = storyboard.instantiateViewControllerWithIdentifier("login") as! LoginViewController
rootViewController = loginViewController
let navigationController = UINavigationController(rootViewController: rootViewController)
window!.rootViewController = navigationController
}
Run Code Online (Sandbox Code Playgroud)
然后在LoginViewController的viewDidAppear()中我要求触摸如下:
LoginViewController.swift:
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
let context = LAContext()
if context.canEvaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, error: nil) {
context.evaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics,
localizedReason: NSLocalizedString("Login To Your Account", comment: ""),
reply: { [weak self] (success, error) in
dispatch_async(dispatch_get_main_queue(), {
if success {
self?.loginUser()
} else if error!.code != LAError.UserCancel.rawValue {
self?.focusOnPassword()
} else
})
}) …
Run Code Online (Sandbox Code Playgroud) Apple声称他们的武器库LAContext中有这个类,但Xcode 8.1告诉我:Use of unresolved identifier 'LAContext'
我的代码行如下:
let context = LAContext()
Run Code Online (Sandbox Code Playgroud)
对我来说,这行代码不会发疯;),所有在线教程都使用这个没问题来检查是否启用了TouchID,但在我的Xcode中,情况并非如此.
我错过了什么?
IOS中的"指纹识别"是否可用,或将来作为API提供?我想从我自己的应用程序中使用它,例如授权用户访问应用程序本身,或登录某些网页.
我知道这可能是一个简单的问题,但我无法在互联网上找到想要的东西。我在项目中使用的是iOS 8中的LocalAuthentication框架,代码在这里:
if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
localizedReason:@"Let's just quickly check that you are the device owner."
reply:^(BOOL success, NSError *error) {
dispatch_async (dispatch_get_main_queue(), ^{
if (error) {
// Error occurred
} else if (success) {
// Device owner, success!
} else {
// Not device owner
}
});
}];
}
Run Code Online (Sandbox Code Playgroud)
但是我想知道用户何时点击“输入密码” LAErrorUserFallback
。但是,我只想知道如何将error
我那里的变量与进行比较,LAErrorUserFallback
以查看结果错误。
我已经试过了:
if (error) {
if (error == LAErrorUserFallback) {
// User tapped 'Enter password'
}
}
Run Code Online (Sandbox Code Playgroud)
但显然这些不是同一类型。
有什么帮助吗?
我正在努力将touchID集成到我的应用程序中.这个过程非常简单,但即使只是使用我的虚拟数据,它在执行任务之前需要大约5秒的时间来验证我的指纹.
这是我的代码:
func requestFingerprintAuthentication() {
let context = LAContext()
var authError: NSError?
let authenticationReason: String = "Login"
if context.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: &authError) {
context.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: authenticationReason, reply: {
(success: Bool, error: NSError?) -> Void in
if success {
println("successfull signin with touchID")
self.emailInputField.text = "john.doe@gmail.com"
self.passwordInputField.text = "password"
self.signIn(self.signInButton)
} else {
println("Unable to Authenticate touchID")
}
})
}
}
Run Code Online (Sandbox Code Playgroud)
即使使用虚拟数据,也需要花费太长时间.
当我正常登录时,通过在我的输入字段中键入电子邮件和密码,signIn()函数立即运行.
看看它是否有问题.我尝试用2行替换它,只需将我带到正确的viewController.但是在对我的指纹进行身份验证后仍需要几秒钟.
我知道这不是手机,也不是touchID.因为它立即运行我的println("使用touchID成功登录").之后是什么,由于某种原因它需要几秒钟才能运行?
任何帮助解释这一点将不胜感激!
我正在将TouchID集成到我的应用中.出于安全考虑,我允许用户打开和关闭它.我想让它在用户添加新指纹时自动关闭.根据Apple的说法,evaluatedPolicyDomainState
仅当canEvaluatePolicy(:error :)方法成功用于生物识别策略或调用evaluatePolicy(:localizedReason:reply :)方法并且执行成功的Touch ID身份验证时,此属性才返回值.否则,返回nil.
返回的数据是不透明的结构.它可用于与此属性返回的其他值进行比较,以确定授权指纹的数据库是否已更新.但是,无法根据此数据确定更改的性质.
但是,我正在添加一个新的指纹并evaluatedPolicyDomainState
保持不变.
有关如何确保evaluatedPolicyDomainState
更新或是否有其他方法检查是否添加新指纹的任何想法?
我正在使用下面的代码快速导航到该Touch ID and Passcode
部分,
guard let profileUrl = URL(string : "App-Prefs:root=TOUCHID_PASSCODE") else {
return
}
if UIApplication.shared.canOpenURL(profileUrl){
if #available(iOS 10.0, *) {
UIApplication.shared.open(profileUrl, options: [:], completionHandler: nil)
} else {
// Fallback on earlier versions
}
}
Run Code Online (Sandbox Code Playgroud)
它在 iOS 10 上工作正常。但现在不起作用。它仅导航至Settings
,而不导航至该Touch ID & Passcode
部分。任何原因。
大家好,我想做一个小问题...我在我的应用程序中使用parse.com.我的用户的登录过程是通过使用parse.com和用户在两个textField中键入的经典方法用户名和密码.
到目前为止一切正常但我想使用TouchID实现另一种登录方法,但是使用parse.com变得很难实现,因为touchID标识了印象,而且用户不在数据库Parse.com中,因此在使用TouchID时我的应用程序返回(正确)错误,因为它无法识别数据库中存在的用户...
有没有人设法使用生物识别TouchID的方法通过parse.com创建的登录??? 或者你知道是否有一种方法可以让我这样做?
谢谢你们
是否可以在应用程序中使用Touch ID传感器,但不能用于登录身份验证?在应用程序中,用户可以扫描另一个人的手指.然后,指纹将与数据库匹配,找到该人的个人资料.
我有一个用Swift制作的iOS应用程序,这是一个小社交网络.用户可以使用登录/密码连接,我将其保存在私人服务器上的数据库中.我想实现TouchID以帮助他们更快地登录.但是,我的用户帐户未与其Apple ID相关联.
// Touch ID button has been clicked
func touchIDButtonClicked() {
print("touchIDButtonClicked");
//Is Touch ID hardware available & configured?
if(authContext.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error:&error))
{
//Perform Touch ID auth
authContext.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: "Connect to the network with your fingertips", reply: {(wasSuccessful:Bool, error:NSError?) in
if(wasSuccessful)
{
//User authenticated
print("OK");
// Log the user
}
else
{
//There are a few reasons why it can fail, we'll write them out to the user in the label
print("NO");
// Tell the user to use his password …
Run Code Online (Sandbox Code Playgroud) 我正在将下面的代码转换为Swift 3.
if context.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error:nil) {
// 2.
context.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics,
localizedReason: "Logging in with Touch ID",
reply: { (success : Bool, error : NSError? ) -> Void in
// 3.
dispatch_async(dispatch_get_main_queue(), {
if success {
self.performSegueWithIdentifier("dismissLogin", sender: self)
}
if error != nil {
var message : NSString
var showAlert : Bool
// 4.
switch(error!.code) {
Run Code Online (Sandbox Code Playgroud)
步骤4在Xcode 8,Swift 3上不再起作用.所以我不能做以下情况:
switch(error!.code) {
case LAError.AuthenticationFailed.rawValue:
message = "There was a problem verifying your identity."
showAlert = true
break;
Run Code Online (Sandbox Code Playgroud)
目前,似乎还没有我能找到的解决方案.有任何建议,请告诉我.
非常感谢!
touch-id ×13
ios ×11
swift ×8
xcode6 ×2
error-code ×1
ios11 ×1
ios8 ×1
ios9 ×1
iphone ×1
login ×1
objective-c ×1
swift3 ×1
url-scheme ×1
xcode ×1