react-native-local-authentication
Local authentication for react native, supports iOS only. See iOS Local Authentication Document
Install
npm i --save react-native-local-authenticationreact-native link react-native-local-authentication
Usage
setLocalizedFallbackTitle(title)
Set fallback button title.
setLocalizedCancelTitle(title)
Set cancel button title.
canEvaluate(policy)
Determines if a particular policy can be evaluated.
Parameters
- policy
The policy to evaluate.
see LAPolicy
Response
Successful
see LABiometryType
- none: No biometry type is supported.
- touchID: The device supports Touch ID.
- faceID: The device supports Face ID.
Failed
- code: see LAError
- message: error message
evaluate(policy, localizedReason)
parameters
- policy
Policy for which the preflight check should be run.
- localizedReason
Policy for which the preflight check should be run.
Response
Successful
return true
Failed
- code: see LAError
- message: error message
invalidate()
Invalidates the context.
LAError
error code
- LAErrorAuthenticationFailed
- LAErrorUserCancel
- LAErrorUserFallback
- LAErrorSystemCancel
- LAErrorPasscodeNotSet
- LAErrorTouchIDNotAvailable
DEPRECATED
- LAErrorTouchIDNotEnrolled
DEPRECATED
- LAErrorTouchIDLockout
DEPRECATED
- LAErrorAppCancel
- LAErrorInvalidContext
- LAErrorNotInteractive
- LAErrorBiometryNotAvailable
- LAErrorBiometryNotEnrolled
- LAErrorBiometryLockout
Example
; async { try const biometryType = await RNLocalAuthentication; if biometryType && biometryType === LABiometryTypetouchID || LABiometryTypefaceID const result = await RNLocalAuthentication; console; Alert; else Alert; catch e console; if === LAErrorLAErrorTouchIDNotAvailable Alert; else Alert; };