Skip to main content

app-host - Host Application

The main host application of the 54VIE Super App, managing authentication, navigation, and bridge handlers.

Overview

app-host is the main React Native application, responsible for:

  • Authentication: Login, SSO, biometric, token management
  • Mini-program loading: Dynamic loading from backend
  • Bridge handlers: 17 service handlers for mini-apps
  • Navigation: Tab navigation, stack navigation

Authentication

Auth Module

app-host/src/auth/
├── AuthProvider.tsx # Context provider
├── services/
│ ├── AuthService.ts # Login, register, logout
│ ├── SSOService.ts # Google, Apple, Facebook
│ └── BiometricService.ts
├── hooks/
│ ├── useAuth.ts # Main auth hook
│ ├── useSSO.ts # SSO hooks
│ └── useBiometric.ts # Biometric hooks
└── utils/
├── TokenManager.ts # JWT management
└── SessionManager.ts # Session tracking

Usage

import { useAuth, useSSO, useBiometric } from '../auth';

function LoginScreen() {
const { login, isLoading } = useAuth();
const { signInWithGoogle, signInWithApple } = useSSO();
const { authenticate: biometricAuth, isSupported } = useBiometric();

// Email login
const handleLogin = async () => {
await login({ email, password });
};

// SSO
const handleGoogleLogin = async () => {
await signInWithGoogle();
};

// Biometric
const handleBiometric = async () => {
if (isSupported) {
const success = await biometricAuth('Login with Face ID');
if (success) {
// Auto-login with stored credentials
}
}
};
}

Bridge Handlers

17 service handlers are registered in AppProviders.tsx:

ServiceMethods
storageget, set, remove, clear
apirequest, registerApi, unregisterApi
authgetUser, isAuthenticated, getAccessToken, requestLogin
analyticstrack, screen
biometricisSupported, isEnabled, authenticate
pushgetToken, requestPermission, scheduleNotification
devicegetInfo, getDeviceId, isEmulator
networkisOnline, getConnectionType
hapticsimpact, notification, selection
clipboardgetString, setString
locationgetCurrentPosition, geocode
mediatakePhoto, pickImage, cropImage
uishowToast, showAlert, showActionSheet
sharetext, image
hostgetInfo
navigationnavigate, goBack

Mini-Program Registry

import { MiniProgramRegistry } from '../services/MiniProgramRegistry';

// Fetch available mini-programs
const programs = await MiniProgramRegistry.getMiniPrograms();

// Get specific program
const program = await MiniProgramRegistry.getMiniProgram('dashboard');

// Track launch
await MiniProgramRegistry.trackLaunch('dashboard');

Bundle Manager

import { BundleManager } from '../services/BundleManager';

// Check if needs update
const needsUpdate = await BundleManager.needsUpdate(programInfo);

// Install bundle
await BundleManager.installBundle(programInfo, (progress) => {
console.log(`Download: ${progress * 100}%`);
});

// Get local manifest URL
const manifestUrl = await BundleManager.getLocalManifestUrl('dashboard');
MainNavigator
├── AuthStack (if not authenticated)
│ └── SignInScreen

└── TabsNavigator (if authenticated)
├── HomeTab
│ └── HomeScreen
├── ServicesTab
│ ├── ServicesScreen (mini-app grid)
│ └── MiniProgramScreen (dynamic)
└── AccountTab
└── AccountScreen