Plugin Marketplace

nativephp/mobile-biometrics

Biometric authentication plugin for NativePHP Mobile (Face ID, Touch ID, Fingerprint)

#Biometrics Plugin for NativePHP Mobile

Biometric authentication plugin for NativePHP Mobile apps. Supports Face ID, Touch ID, and fingerprint authentication.

#Overview

The Biometrics API allows you to authenticate users using their device's biometric sensors like Face ID, Touch ID, or fingerprint scanners.

#Installation

Copied!
composer require nativephp/mobile-biometrics

#Usage

#PHP (Livewire/Blade)

Copied!
use Native\Mobile\Facades\Biometrics;
 
Biometrics::prompt();

#JavaScript (Vue/React/Inertia)

Copied!
import { biometric, on, off, Events } from '#nativephp';
 
// Basic usage
await biometric.prompt();
 
// With an identifier for tracking
await biometric.prompt()
.id('secure-action-auth');

#Events

#Completed

Fired when biometric authentication completes (success or failure).

PHP

Copied!
use Native\Mobile\Attributes\OnNative;
use Native\Mobile\Events\Biometric\Completed;
 
#[OnNative(Completed::class)]
public function handle(bool $success)
{
if ($success) {
// User authenticated successfully
$this->unlockSecureFeature();
} else {
// Authentication failed
$this->showErrorMessage();
}
}

Vue

Copied!
import { biometric, on, off, Events } from '#nativephp';
import { ref, onMounted, onUnmounted } from 'vue';
 
const isAuthenticated = ref(false);
 
const handleBiometricComplete = (payload) => {
if (payload.success) {
isAuthenticated.value = true;
unlockSecureFeature();
} else {
showErrorMessage();
}
};
 
const authenticate = async () => {
await biometric.prompt();
};
 
onMounted(() => {
on(Events.Biometric.Completed, handleBiometricComplete);
});
 
onUnmounted(() => {
off(Events.Biometric.Completed, handleBiometricComplete);
});

React

Copied!
import { biometric, on, off, Events } from '#nativephp';
import { useState, useEffect } from 'react';
 
const [isAuthenticated, setIsAuthenticated] = useState(false);
 
const handleBiometricComplete = (payload) => {
if (payload.success) {
setIsAuthenticated(true);
unlockSecureFeature();
} else {
showErrorMessage();
}
};
 
const authenticate = async () => {
await biometric.prompt();
};
 
useEffect(() => {
on(Events.Biometric.Completed, handleBiometricComplete);
 
return () => {
off(Events.Biometric.Completed, handleBiometricComplete);
};
}, []);

#Platform Support

  • iOS: Face ID, Touch ID
  • Android: Fingerprint, Face unlock, other biometric methods
  • Fallback: System authentication (PIN, password, pattern)

#Security Notes

  • Biometric authentication provides convenience, not absolute security
  • Always combine with other authentication factors for sensitive operations
  • Consider implementing session timeouts for unlocked states
  • Users can potentially bypass biometrics if their device is compromised