biometric

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

View Source
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

func Authenticate(a *tango.App, o Options) error

Authenticate shows the system prompt and waits; nil means the owner was verified.

func String

func String(k Kind) string

String names k: "none", "touchID", "faceID", "opticID", "biometric".

Types

type Kind

type Kind = platform.BiometryKind

Kind is the biometry the device offers.

func Available

func Available(a *tango.App) (Kind, error)

Available reports the device's biometry. When it is None, err says why (ErrNotAvailable, ErrNotEnrolled, ErrLockedOut).

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL