Documentation
¶
Overview ¶
Package biometric verifies the device owner with Face ID / Touch ID (iOS, macOS) or BiometricPrompt (Android 9+).
if err := biometric.Authenticate(a, biometric.Options{Reason: "Unlock your notes"}); err != nil {
// ErrCanceled, ErrFailed, ErrNotEnrolled, ErrLockedOut, ErrNotAvailable ...
}
iOS needs NSFaceIDUsageDescription in Info.plist (permission "biometric" in tan.json); without it Authenticate returns ErrNotConfigured instead of crashing. Android needs android.permission.USE_BIOMETRIC.
Functions return ErrUnsupported where the backend has no biometrics and tango.ErrNotRunning after the app quit. On Android call Authenticate from a goroutine, not from a main-thread callback.
Index ¶
Constants ¶
const ( None = platform.BiometryNone TouchID = platform.BiometryTouchID // also Android fingerprint FaceID = platform.BiometryFaceID // also Android face OpticID = platform.BiometryOpticID Other = platform.BiometryOther // available, kind not reported (Android) )
Variables ¶
var ( ErrUnsupported = platform.ErrUnsupported ErrCanceled = platform.ErrCanceled ErrFailed = platform.ErrAuthFailed ErrNotAvailable = platform.ErrNotAvailable ErrNotEnrolled = platform.ErrNotEnrolled ErrLockedOut = platform.ErrLockedOut ErrNotConfigured = platform.ErrNotConfigured )
Functions ¶
func Authenticate ¶
Authenticate shows the system prompt and waits; nil means the owner was verified.
Types ¶
type Options ¶
type Options struct {
Reason string // why the app asks; required on iOS/macOS
Title string // Android prompt title (default: the app name)
CancelTitle string // cancel button label; "" = system default
AllowPasscode bool // let the user fall back to the device passcode / PIN
// contains filtered or unexported fields
}
Options configures the prompt.