pediatric-ai-scribe-v3/mobile
Daniel 8f49c4dcb9 feat(mobile): biometric sign-in (Face ID / Touch ID / fingerprint)
Adds opt-in biometric login to the Capacitor app. Replaces the password
step on subsequent sign-ins; the 2FA step (if any) still applies — by
design, defense in depth.

How it works:
- After a successful password sign-in on a Capacitor build, prompt the
  user to enroll. If they accept, capacitor-native-biometric.setCredentials
  stores the (email, password) pair in the iOS Keychain / Android Keystore
  with biometric-protected access. The local flag ped_bio_enabled=1 is
  set so the next launch knows to probe.
- On the login form, if isNativeApp() + bioStored() + bioAvailable.ok,
  reveal the "Sign in with Face ID / Touch ID / fingerprint" button at
  the top. Label is set from the actual biometryType returned by the
  plugin so users see what their device supports.
- Tap → verifyIdentity (OS prompt) → getCredentials → fill the email +
  password fields → fire the existing form submit so all the regular
  flow runs (turnstile, 2FA prompt, error handling, session storage).
- Explicit logout deletes credentials AND clears the local flag,
  hiding the button on the next visit. Auto-logout (token expiry,
  network) does NOT come through that path, so biometric persists
  across silent session resets.

Storage choice — password not JWT:
- JWTs expire and the storage would constantly need refresh.
- Storing the password lets the standard /api/auth/login flow run,
  which already handles password-rotation (a stale stored password
  just fails 401 → user falls back to typing the new one → re-enrolls).
- The password sits in OS-level secure storage, accessible only after
  successful biometric verification — same security posture as a
  password manager autofill.

Files:
- mobile/package.json: add capacitor-native-biometric@^5.0.0 (Capacitor 6
  compat)
- mobile/android/app/src/main/AndroidManifest.xml: add USE_BIOMETRIC
  uses-permission
- mobile/ios/App/App/Info.plist: add NSFaceIDUsageDescription string
- public/js/auth.js: bioPlugin/bioAvailable/bioStored/bioEnroll/
  bioRetrieve/bioForget helpers; window.PedBio surface; reveal-on-load;
  click handler; post-login enrollment prompt; logout cleanup
- public/index.html: hidden #btn-bio-login + #bio-divider above the
  email field on the login form
- public/css/styles.css: themed gradient button + hover lift
- mobile/README.md: feature list updated

Build steps for Daniel:
  cd mobile && npm install        # picks up capacitor-native-biometric
  npx cap sync                    # ports the plugin into android/ + ios/
  # then build APK / IPA as usual
2026-04-28 03:09:38 +02:00
..
android feat(mobile): biometric sign-in (Face ID / Touch ID / fingerprint) 2026-04-28 03:09:38 +02:00
ios feat(mobile): biometric sign-in (Face ID / Touch ID / fingerprint) 2026-04-28 03:09:38 +02:00
src Fix Android mic permission, simplify launcher, remove broken biometric 2026-04-11 03:34:47 +02:00
.gitignore Add mobile/.gitignore (should have been in prior cleanup commit) 2026-04-14 23:39:26 +02:00
capacitor.config.json Mobile app hardening — security + Android 14 compat 2026-04-14 04:15:27 +02:00
package-lock.json Add biometric auth, ntfy push notifications, mobile improvements 2026-04-11 02:35:07 +02:00
package.json feat(mobile): biometric sign-in (Face ID / Touch ID / fingerprint) 2026-04-28 03:09:38 +02:00
README.md feat(mobile): biometric sign-in (Face ID / Touch ID / fingerprint) 2026-04-28 03:09:38 +02:00

PedScribe Mobile App

Native mobile wrapper for Pediatric AI Scribe using Capacitor. Provides background audio recording, push notifications, haptic feedback, deep linking, and share intent support on both iOS and Android.

Features

  • Background recording that survives screen lock (foreground service on Android, background audio on iOS)
  • Configurable server URL (supports self-hosted instances)
  • Haptic feedback on recording start/stop
  • Keep screen awake during recording
  • Deep linking (pedscribe:// and https://app.pedshub.com)
  • Share intent (receive text/PDFs from other apps)
  • Push notification support
  • Biometric sign-in (Face ID / Touch ID / fingerprint) — credentials stored in iOS Keychain / Android Keystore, gated by OS biometric. Enrolled on first password sign-in (opt-in prompt). 2FA still applies on top — biometric replaces the password step only.
  • App Store and Play Store ready

Prerequisites

  • Node.js 18+
  • Android Studio (for Android builds): sudo snap install android-studio --classic
  • Xcode 15+ (for iOS builds, macOS only)
  • Apple Developer account ($99/yr for App Store)
  • Google Play Developer account ($25 one-time)

Setup

cd mobile
npm install
npx cap sync

Build Android

# Open in Android Studio
npx cap open android

# Build menu: Build > Generate Signed Bundle / APK > APK
# Sign with your keystore (create one on first build)
# APK output: android/app/build/outputs/apk/release/

# Or build from command line:
cd android && ./gradlew assembleRelease

Build iOS (macOS only)

# Open in Xcode
npx cap open ios

# In Xcode:
# 1. Select your team/signing certificate
# 2. Product > Archive
# 3. Distribute App > App Store Connect

How It Works

  1. App launches with a local launcher page
  2. First launch: user enters their PedScribe server URL (default: app.pedshub.com)
  3. URL is saved locally for future launches
  4. App navigates to the remote web app inside a native WebView
  5. Native plugins provide background recording, haptics, and push notifications

Background Recording

Android: AudioRecordingService is a foreground service that:

  • Acquires a partial wake lock (CPU stays active, screen can sleep)
  • Shows a persistent notification ("Recording in progress...")
  • Includes a "Stop Recording" quick action in the notification
  • Maximum 1-hour wake lock duration

iOS: Uses UIBackgroundModes: audio in Info.plist, which tells iOS to keep the app alive for audio capture when backgrounded or screen-locked.

Deep Linking

  • pedscribe:// custom URL scheme opens the app directly
  • https://app.pedshub.com links open in the app instead of the browser (Android App Links)

Share Intent (Android)

Other apps can share text or PDFs directly into PedScribe:

  • Share a lab result from your email into the Chart Review tab
  • Share a referral note into the Hospital Course tab

Capacitor Plugins Included

Plugin Purpose
@capacitor/app App lifecycle management
@capacitor/haptics Vibration feedback on recording start/stop
@capacitor/keyboard Keyboard management for WebView
@capacitor/push-notifications Push notification support
@capacitor/screen-orientation Screen orientation control
@capacitor/share Native share dialog
@capacitor/splash-screen Launch splash screen
@capacitor/status-bar Status bar styling

App Structure

mobile/
  capacitor.config.json    # Capacitor configuration
  package.json             # Dependencies
  src/
    index.html             # Launcher page (server URL config)
    launcher.js            # Auto-redirect + native feature init
    launcher.css            # Launcher styles
  android/                 # Android native project
    app/src/main/
      java/com/pedshub/scribe/
        MainActivity.java
        AudioRecordingService.java
      AndroidManifest.xml  # Permissions, deep links, share intent
  ios/                     # iOS native project
    App/App/
      Info.plist           # Background audio, microphone, deep links

Updating the Web App

The mobile app wraps the remote web app — updating the server automatically updates all mobile clients. No app store update needed for web changes.

To update native features (plugins, permissions, splash screen):

cd mobile
npm install
npx cap sync
# Then rebuild in Android Studio / Xcode

Generating App Icons

Replace the default Capacitor icons with PedScribe branding:

  1. Create a 1024x1024 PNG icon
  2. Install the assets tool: npm install -D @capacitor/assets
  3. Place your icon as assets/icon-only.png and assets/splash.png
  4. Run: npx capacitor-assets generate

This generates all required sizes for both platforms.

App Store Listing Suggestions

Title: PedScribe - Pediatric AI Scribe Subtitle: Voice-to-Note Clinical Documentation Category: Medical Keywords: pediatric, scribe, medical, documentation, HPI, SOAP, clinical, AI, voice

Description: PedScribe is an AI-powered clinical documentation tool for pediatric physicians. Record patient encounters, and the AI generates structured medical notes — HPIs, SOAP notes, hospital courses, chart reviews, and more. Includes pediatric calculators, developmental milestone tracking, and a learning hub with quizzes. Self-hosted for maximum privacy with HIPAA-compliant AI providers.