mjwheatley / cordova-plugin-android-fingerprint-auth

A cordova plugin for fingerprint authentication using the hardware fingerprint scanner on devices running Android 6+
Apache License 2.0
168 stars 131 forks source link

Issue with fingerprint #44

Closed burhanfarooqws closed 7 years ago

burhanfarooqws commented 7 years ago

I am using this plugin in my cordova project using visual studio.

The code below seems to failed when run in any device where as the finger print is supported on the device.


// For an introduction to the Blank template, see the following documentation: // http://go.microsoft.com/fwlink/?LinkID=397704 // To debug code on page load in Ripple or on Android devices/emulators: launch your app, set breakpoints, // and then run "window.location.reload()" in the JavaScript Console. (function () { "use strict";

document.addEventListener( 'deviceready', onDeviceReady.bind( this ), false );

function onDeviceReady() {
    // Handle the Cordova pause and resume events
    document.addEventListener( 'pause', onPause.bind( this ), false );
    document.addEventListener( 'resume', onResume.bind( this ), false );

    // TODO: Cordova has been loaded. Perform any initialization that requires Cordova here.
    var parentElement = document.getElementById('deviceready');
    var listeningElement = parentElement.querySelector('.listening');
    var receivedElement = parentElement.querySelector('.received');
    listeningElement.setAttribute('style', 'display:none;');
    receivedElement.setAttribute('style', 'display:block;');

    alert(FingerprintAuth);
    FingerprintAuth.isAvailable(isAvailableSuccess, isAvailableError);
};

function isAvailableSuccess(result) {
    console.log("FingerprintAuth available: " + JSON.stringify(result));
    alert(result.isAvailable);
    if (result.isAvailable) {
        var encryptConfig = {
            clientId: "myAppName",
            username: "currentUser",
            password: "currentUserPassword"
        }; // See config object for required parameters
        FingerprintAuth.encrypt(encryptConfig, successCallback, errorCallback);
    }
}

function isAvailableError(message) {
    console.log("isAvailableError(): " + message);
}

function successCallback(result) {
    console.log("successCallback(): " + JSON.stringify(result));
    if (result.withFingerprint) {
        console.log("Successfully encrypted credentials.");
        console.log("Encrypted credentials: " + result.token);
    } else if (result.withBackup) {
        console.log("Authenticated with backup password");
    }
}

function errorCallback(error) {
    if (error === "Cancelled") {
        console.log("FingerprintAuth Dialog Cancelled!");
    } else {
        console.log("FingerprintAuth Error: " + error);
    }
}

function onPause() {
    // TODO: This application has been suspended. Save application state here.
};

function onResume() {
    // TODO: This application has been reactivated. Restore application state here.
};

} )();


What could possibly be wrong as the android emulator also able to run plugin, really can't figure out the issue. The plugin execute but simple return false that fingerprint not supported. Do I have to give special permission to App or inside mobile allow some option.

any help would be appreciated.

burhanfarooqws commented 7 years ago

Complete code can be seen here: https://github.com/burhanfarooqws/CordovaFingerPrint

mjwheatley commented 7 years ago

What devices have you tested on? The Samsung GS5 does not support the Google Fingerprint API. Also check to make sure the USE_FINGERPRINT permission was copied from the plugin to your app's manifest.

burhanfarooqws commented 7 years ago

unnamed I am using galaxy note 4 with marshmallow. I installed diagnostic plugin which gives this error. As you mentioned earlier i have added permission in manifest file. I also extract apk to further check if it got copy or not the xml tags are there .... now is this the case with debug build as i am testing or should i make a release build with proper certificate as i install using adb install command and no permission dialogue comes when installing even manually ... bit confused ... what i am doing wrong.

mjwheatley commented 7 years ago

Have you enrolled a fingerprint on the device? Will you go to the app manager and check the permissions requested for your application and tell me what you see? When I was testing the code I added to check for permissions, when I checked my app permissions it said "No permissions requested" but I was still able to use the plugin.

burhanfarooqws commented 7 years ago

yes finger print is enrolled on android. app manager gives this to me: screenshot_2017-01-07-16-22-17 screenshot_2017-01-07-16-22-05 screenshot_2017-01-07-16-22-10

Have you tested my code git hub sample ?

mjwheatley commented 7 years ago

I just tested your github sample project on my Nexus 6p and it worked just fine.

mjwheatley commented 7 years ago

Android FingerPrint API isHardwareDetected returns false for Samsung Note 4 Accepted answer on stackoverflow: "I'm afraid the Note 4 doesn't support the Fingerprint API (just the Samsung Fingerprint). You should try your code with another device if possible."

burhanfarooqws commented 7 years ago

Thanks @mjwheatley