Sensors, Haptics & Biometrics
Use the accelerometer, gyroscope and other sensors, give tactile feedback with haptics, and unlock features with Face ID or fingerprint.
Intermediate · about 5 hours · difficulty 3/5
Learn first: Runtime Permissions & Privacy, Local Storage: Key-value, SQLite & Files
Phones are packed with hardware that web apps rarely touch. A few well-chosen uses make an app feel truly mobile.
Sensors
- Accelerometer and gyroscope for shake gestures, tilt effects and motion games.
- Magnetometer for compass headings, barometer for altitude, pedometer for step counts.
- Libraries: expo-sensors, sensors_plus, Android
SensorManager, iOS Core Motion. - Subscribe only while needed and choose a sensible update interval; high-frequency sensor streams cost battery and CPU.
Haptics
Short vibrations confirm actions (success, warning, selection change). Use expo-haptics, HapticFeedback in Flutter, or the platform APIs. Keep them subtle and meaningful.
Biometrics
Face ID, Touch ID and Android BiometricPrompt let users confirm identity locally (expo-local-authentication, local_auth).
- Biometrics unlock something already on the device (a stored token or key); they do not authenticate the user to your server by themselves.
- For stronger security, tie a Keychain/Keystore item to biometric access so the secret cannot be read without a successful scan.
- Always provide a fallback (device passcode or password). iOS needs
NSFaceIDUsageDescription.
Good enough to move on: your app can lock sensitive screens behind biometrics with a fallback, and uses haptics for key confirmations.
Key concepts
- Accelerometer and gyroscope
- Pedometer and other sensors
- Sensor update intervals and battery
- Haptic feedback
- Face ID, Touch ID and BiometricPrompt
- Biometric-protected secure storage
- Fallback authentication
Mini project
Build a private notes app that requires biometrics to open, supports a passcode fallback, and clears the screen when you shake the phone.
Check yourself
Why does a successful Face ID check alone not prove to your server who the user is?
Free resources
- Expo LocalAuthentication (Expo)
- Expo Sensors (Expo)
- Android: Show a biometric dialog (Android Developers)