Skip to content

callbackErrorTouchId doesn't catch all possible errors. #213

@findiel

Description

@findiel

As we can see in react-native-touch-id library documentation (Errors section), errors could come from TouchID.isSupported or TouchID.authenticate methods.
In this lib we have such code:
https://github.com/jarden-digital/react-native-pincode/blob/master/src/PinCodeEnter.tsx

  triggerTouchID() {
    !!TouchID && TouchID.isSupported()
      .then(() => {
        setTimeout(() => {
          this.launchTouchID()
        })
      })
      .catch((error: any) => {
        console.warn('TouchID error', error)
      })
  }

and

  async launchTouchID() {
    const optionalConfigObject = {
      imageColor: '#e00606',
      imageErrorColor: '#ff0000',
      sensorDescription: 'Touch sensor',
      sensorErrorDescription: 'Failed',
      cancelText: this.props.textCancelButtonTouchID || 'Cancel',
      fallbackLabel: 'Show Passcode',
      unifiedErrors: false,
      passcodeFallback: this.props.passcodeFallback
    }
    try {
      await TouchID.authenticate(
        this.props.touchIDSentence,
        Object.assign({}, optionalConfigObject, {
          title: this.props.touchIDTitle
        })
      ).then((success: any) => {
        this.endProcess(this.props.storedPin || this.keyChainResult)
      })
    } catch (e) {
      if (!!this.props.callbackErrorTouchId) {
        this.props.callbackErrorTouchId(e)
      } else {
        console.log('TouchID error', e)
      }
    }
  }

So it seems that we can't handle with errors from TouchID.isSupported, because callbackErrorTouchId callback is triggering only if TouchID.authenticate fails.
Could you fix that please?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions