A common pain-point for Titanium developers is implementing fingerprint authentication for Android. Hyperloop (especially now that it’s free) solved the technical challenge but the UI/Presentation layer still remained left to the developer.
I recently took Google’s Material Guideline for Fingerprint Behavior and created my own Titanium Widget to solve that issue and make it portable for use in several of my other apps.
1- Appcelerator/Titanium
2- Hyperloop
3- Some method of fingerprint authentication.
a. TouchID — https://github.com/appcelerator-modules/ti.touchid
OR
b. Ti.Reprint Hyperloop .aar and common.js — https://github.com/loop-modules/Ti.Reprint
4- ti.androidfingerprintalertdialog widget — https://github.com/adamtarmstrong/ti.androidfingerprintalertdialog
a. Copy the github file /Ti.Reprint/app/platform/android/core-2.8.3.aar to your ‘project’/app/platform/android/ folder
Reprint is a unified fingerprint authentication library for Android that supports multiple fingerprint APIs — including Imprint & Samsung Pass. https://github.com/ajalt/reprint
b. Copy the github file /Ti.Reprint/app/lib/Reprint.js to your ‘project’/app/lib/ folder
This library provides various methods to initialize, authenticate, check if device supports fingerprint, verifies fingerprints are registered, and more.
c. Update your tiapp.xml file to allow your app to use android.permission.USE_FINGERPRINT
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
a. Download/extract widget and copy the ‘ti.androidfingerprintalertdialog’ folder to your ‘project/app/widgets/ folder
b. Update your ‘project’/app/config.json file to add the widget
"dependencies": {
"ti.androidfingerprintalertdialog": "1.0"
}
index.xml
<Widget id="androidFingerprint" src="ti.androidfingerprintalertdialog" />
index.js
var Reprint = require('reprint');
Reprint.initialize();
function successCallback(moduleTag) {
$.androidFingerprint.success();
//Continue login process
}
function failureCallback(failureReason, fatal, errorMessage, moduleTag, errorCode) {
$.androidFingerprint.failure();
}
function fingerprintUsePassword(){
Reprint.cancelAuthentication();
}
function fingerprintCancel(){
Reprint.cancelAuthentication();
}
Verify that device BOTH has the hardware and a fingerprint is registered
if (Reprint.isHardwarePresent() && Reprint.hasFingerprintRegistered())
$.androidFingerprint.show(fingerprintUsePassword, fingerprintCancel);
The Widget Repo and full implementation example can be found here. Contributions welcomed!