I am working on the app that uses touch ID for login. It should ask for touch ID only at first launch (i.e. I am not asking for touch ID auth when app enters foreground from background). Here is what I do to show 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
}
Then in viewDidAppear() of LoginViewController I ask for touch like so:
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
})
})
} else {
loginUser()
}
}
The problem is some of testers report that they are not getting TouchID alert at all. It just show shows password screen right away. I added error logging and the error I receive is:
Domain: com.apple.LocalAuthentication Code: -1004 NSLocalizedDescription: User interaction is required.
And I can't reproduce it at all. Touch ID works fine on all of my test devices, so I can't get the reason of that. Bugs were received from iPhone 6, 6S, 6s Plus, iOS 9.3.1-9.3.3.
This happens on iOS 10 even when your application is in the foreground. As mentioned by Android Noob in one of the comments.
I did further investigation and found that it happens when you have multiple apps with the same product/executable name.
In my scenario I had 3 versions of the same app(code) with different bundle identifiers and display names. Only one of them, the last one that was installed, worked with Touch ID. The others returned the 'User interaction required error'.
Regarding the OP's issue. It is likely that the testers have another app with the same executable name installed on their devices. This could be another version of your app or another developer's app.
To circumvent the issue, change your executable or product name: Targets -> [Your Target Name] -> Build Settings -> Packaging -> Product Name
My tests and findings:
Given 3 apps with same code and product name but different bundle ids and display names: CI, UAT and Prod.
Install CI:
Install UAT:
Install Prod:
Uninstall Prod:
Uninstall UAT and CI, reinstall CI:
Change UAT product name and install UAT:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With