EddyVerbruggen / cordova-plugin-touch-id

:nail_care: 👱‍♂️ Forget passwords, use a fingerprint scanner!
MIT License
214 stars 72 forks source link

isAvailable success function not working #44

Open thomstark opened 6 years ago

thomstark commented 6 years ago

I'm using the latest version of Phonegap and the npm install of your plugin.

    window.plugins.touchid.isAvailable(
    function(){alert('available')}, // success handler: TouchID available
    function(){alert('not available')} // error handler: no TouchID available
); 

The error message works correctly in the browser and on Android, but the success alert isn't firing on my iPhone 6s.

This is my first day working with Phonegap so I have a bit of a curve.

vagishmm commented 6 years ago

I'm also facing same isssue

vagishmm commented 6 years ago

I think this plugin is not updated for newer Cordova version. I found solution, please check your ios version in Cordova $ cordova platform version if it shows ios version is 4.4.0, then it won't work. Just try below command and try to execute isAvailable function. $ cordova platform update ios@4.0.0

Above solution works for me.

CobusKruger commented 6 years ago

I tried @vagishmm solution of downgrading the platform, but this caused a number of other problems for me, so I reverted.

I'm really stuck here. isAvailable is an important check to do, but it never, ever fires the success handler, be it on the emulator or a real phone. Without it, the plugin can't be used. That's a problem, since most alternatives appear to be forks of this.

Any idea what's involved in converting to the new platform versions?

@EddyVerbruggen have you been able to recreate this at all?

Edit I don't know how I missed it before, but there is actually some output in the Xcode debugger:

2018-02-01 16:30:51.122871+0200 C-Cube[4726:541703] ERROR: Plugin 'TouchID' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2018-02-01 16:30:51.123092+0200 C-Cube[4726:541703] -[CDVCommandQueue executePending] [Line 142] FAILED pluginJSON = ["TouchID476529521","TouchID","isAvailable",[]]

There are two config.xml files, although I thought the one in /platforms/ios/myproject was generated from the one in /.

/config.xml only has this one reference to the plugin, which doesn't have the "TouchID" referenced in the error message:

<plugin name="cordova-plugin-keychain-touch-id" spec="https://github.com/MobilidadeBPI/cordova-plugin-keychain-touch-id" />

/platforms/ios/myproject/config.xml references "TouchID" , but I'm not sure how that is linked up with the actual plugin code (I think it simply matches the filename):

<feature name="TouchID">
    <param name="ios-package" value="TouchID" />
</feature>

And TouchID.h has the following declaration, which clearly declares it as a CDVPlugin:

@interface TouchID : CDVPlugin {}

So I have no clue why the message comes up. I also checked case usage right through, but saw nothing suspicious.

CobusKruger commented 6 years ago

I got it working by re-adding ./www as a reference to the XCode project. I have no idea why that helped, and I have no idea why all the other plugins worked and this one didn't. But it least it got me past this problem.

fmp777 commented 6 years ago

@CobusKruger can you clarify what you did more specifically?

karthi431Reddy commented 6 years ago

where can I add this code

window.plugins.touchid.isAvailable( function(){alert('available')}, // success handler: TouchID available function(){alert('not available')} // error handler: no TouchID available ); means in which file