naoufal / react-native-touch-id

React Native authentication with the native Touch ID popup.
https://www.npmjs.com/package/react-native-touch-id
1.47k stars 476 forks source link

TouchID.isSupported was called with 2 arguments #227

Closed MaximeConan closed 5 years ago

MaximeConan commented 5 years ago

Hello,

I have the following error using your library :

Runtime Exception: TouchID.isSupported was called with 1 arguments but expects 2 arguments..

I have try to reset my cache, delete and reinstalle my node_modules but anything works. I'm using the 4.4.1 version.

jorisw commented 5 years ago

Judging from the changes in https://github.com/naoufal/react-native-touch-id/commit/e1d3ab985366edc69732f908efdd7e6e2b9e10a3, it looks like instead of:

TouchID.isSupported(callback)

You should now call:

TouchID.isSupported(config, callback)

For example:

TouchID.isSupported({}, (error, biometryType) => {
   console.log({
      error, 
      biometryType,
   })
})

Hope this helps.

MaximeConan commented 5 years ago

Hey thanks for your help @jorisw , unfortunately I'have still the same error using your snippet 😢

MaximeConan commented 5 years ago

To resolve my issue I have change my code to this :

import { NativeModules } from 'react-native'

const NativeTouchID = NativeModules.TouchID
     const result = new Promise((resolve, reject) => {
           NativeTouchID.isSupported((error, biometryType) => {
        if (error) {
            return reject(createError(config, error.message))
        }
    resolve(biometryType)
       })
})

So I use directly isSupported method on the NativeTouchID, works perfectly if it can helps someone 👍