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

callbacks always called #7

Closed charlesmccann closed 8 years ago

charlesmccann commented 8 years ago

Using the example code, I modified it for my phonegap "app". I'm running this on my Android device (Galaxy s7). The .isAvailable() code runs fine.

However, the .show() always calls the callback before the fingerprint has even been used. So, when cancelling, these are the 2 alerts print every time: success: OK withFingerprint: undefined fail: Cancelled

Is this the desired behavior? are we to watch for specific messages to know if it is truly success or failure?

FingerprintAuth.isAvailable(isAvailableSuccess, isAvailableError);

    isAvailableSuccess: function(result) {
        console.log("FingerprintAuth available: " + JSON.stringify(result));
        if (result.isAvailable) {
            FingerprintAuth.show({
                        clientId: "myAppName",
                        clientSecret: "a_very_secret_encryption_key"
                    }, app.successcallback, app.failcallback);
        }
    },
    successcallback: function(msg) {
        app.showData();
        alert("success: "+msg + " withFingerprint:" + msg.withFingerprint);
    },
    failcallback: function(msg) {
        alert("fail: " + msg);
    },
ghost commented 8 years ago

+1

mjwheatley commented 8 years ago

No that is not the desired behavior. I recently added the callback for the cancel message and in doing so I probably caused this bug. I will sort through the code and see if I can prevent the false success callback.

mjwheatley commented 8 years ago

published v0.0.10 to resolve this issue

ghost commented 8 years ago

It's working correctly now. Thanks!

charlesmccann commented 8 years ago

Yes, thank you!