tidev / titanium-identity

A collection of API's to authenticate with your device: Keychain/Keystore, Touch ID and Face ID
Other
39 stars 28 forks source link

feat(android) null check and new check properties #309

Open m1ga opened 2 years ago

m1ga commented 2 years ago

Resolves #301

var win = Ti.UI.createWindow();
var TiIdentity = require('ti.identity');
TiIdentity.authenticationPolicy = TiIdentity.AUTHENTICATION_POLICY_BIOMETRICS;

var supported = TiIdentity.isSupported();
console.log("is supported: ", supported);

console.log("hasFingerprintScanner: ", TiIdentity.hasFingerprintScanner);
console.log("hasFaceScanner: ", TiIdentity.hasFaceScanner);
console.log("hasIrisScanner: ", TiIdentity.hasIrisScanner);

if (TiIdentity.authenticationPolicy === TiIdentity.AUTHENTICATION_POLICY_BIOMETRICS) {
        authPhrase = 'Touch ID';
} else if (TiIdentity.authenticationPolicy === TiIdentity.AUTHENTICATION_POLICY_PASSCODE) {
    authPhrase = 'Device Passcode';
}
Ti.API.info("AUTPHRASE: " + authPhrase);

function onOpen(e) {
    if (!supported) {
        alert('Authentication is not supported on this device!');
        return;
    }
    TiIdentity.authenticate({
        reason: 'Can we access this content?',
        callback: function(e) {
            Ti.API.info(e);
        }
    });
}

win.addEventListener("open", onOpen)
win.open();

ti.identity-android-3.1.1.zip

m1ga commented 1 year ago

a bit confused why I have to add the github actions again :thinking: but it thinks the master has the old actions :shrug:

jordanbisato commented 1 year ago

After using this version, i didn't get the #301 error anymore.