iPhone fingerprint recognition
In August 2013 (before Touch ID or the iPhone 5s were released) I wrote a blog post guessing that the hardware and software capabilities of fingerprint recognition could be just around the corner and might become available to app developers.
Apple, to much disappointment, kept the API private with iOS 7 but this has all changed with the (beta) release of iOS 8. Now, you got the touch…
The local authentication framework
The moment Xcode 6 beta had finished downloading, the first thing I did was create a dummy project with the newly available “Local Authentication” framework. It took me quite some time to realise that adding the reference (either
#import <LocalAuthentication/LocalAuthentication.h> or as a module
@import LocalAuthentication) broke the build if you don’t target a real device (learn from me here and save yourself some time!).
Cordova / PhoneGap plugin
Add the plugin with the CLI
Using the plugin
Ensure you use the plugin after your deviceready event has been fired and you are targeting a real device.
Pass the following arguments to the
authenticate() function, to prompt the user to authenticate via TouchID:
- Success callback (called on successful authentication)
- Failure callback (called on error or if authentication fails)
- Localised text explaining why the app needs authentication. This should be localised and provide a clear reason for why you are requesting that the user performs the authentication, and what action you will be taking.
authenticate() function will return an error if the user is unable to authenticate via Touch ID, you may wish to check support without prompting the user to authenticate. This can be done by passing following arguments to the
- Success callback (called if authentication is possible)
- Not supported callback (called if policy can not be evaluated, with error message)
Probably. Issues and pull request on the git repo please. Remember this is still beta.