var TouchID = require('ti.touchid');
keychainItem = TouchID.createKeychainItem({
identifier: 'test_key',
accessControlMode: TouchID.ACCESS_CONTROL_TOUCH_ID_ANY // remove this to save without fingerprint authentication
}),
win = Ti.UI.createWindow({backgroundColor: 'white', layout: 'vertical'});
queue = [],
callback = function(e) {
if (queue.length) {
queue.shift().close();
}
alert(JSON.stringify(e, null, 1));
};
keychainItem.addEventListener('save', callback);
keychainItem.addEventListener('read', callback);
keychainItem.addEventListener('reset', callback);
keychainItem.addEventListener('update', callback);
button('SAVE', function() {
showFingerprint();
keychainItem.save('86c8153c-6d2c-421a-8e79-eae8ad0831ba');
});
button('READ', function() {
showFingerprint();
keychainItem.read();
});
button('RESET', function() {
showFingerprint();
keychainItem.reset();
});
button('UPDATE', function() {
showFingerprint();
keychainItem.update('test_update');
});
win.open();
function showFingerprint() {
if (keychainItem.accessControlMode !== TouchID.ACCESS_CONTROL_TOUCH_ID_ANY) return;
var win = Ti.UI.createWindow({backgroundColor: 'white'}),
img = Ti.UI.createImageView({image: 'http://bit.ly/2ur2X4u', width: 64, height: 64});
queue.push(win);
win.add(img);
win.open();
}
function button(title, click) {
var btn = Ti.UI.createButton({title: title, width: Ti.UI.FILL});
btn.addEventListener('click', click);
win.add(btn);
}
- SAVE and then READ data
- READ callback should return the full string