Files
digital-pilates/services/version.ts
richarjiang a309123b35 feat(app): add version check system and enhance internationalization support
Add comprehensive app update checking functionality with:
- New VersionCheckContext for managing update detection and notifications
- VersionUpdateModal UI component for presenting update information
- Version service API integration with platform-specific update URLs
- Version check menu item in personal settings with manual/automatic checking

Enhance internationalization across workout features:
- Complete workout type translations for English and Chinese
- Localized workout detail modal with proper date/time formatting
- Locale-aware date formatting in fitness rings detail
- Workout notification improvements with deep linking to specific workout details

Improve UI/UX with better chart rendering, sizing fixes, and enhanced navigation flow. Update app version to 1.1.3 and include app version in API headers for better tracking.
2025-11-29 20:47:16 +08:00

30 lines
878 B
TypeScript

import { api } from '@/services/api';
import Constants from 'expo-constants';
import { Platform } from 'react-native';
export type VersionInfo = {
latestVersion: string;
appStoreUrl: string;
needsUpdate: boolean;
updateMessage?: string;
releaseNotes?: string;
};
export function getCurrentAppVersion(): string {
return Constants.expoConfig?.version || Constants.nativeAppVersion || '0.0.0';
}
function getPlatformParam(): 'ios' | 'android' | undefined {
if (Platform.OS === 'ios') return 'ios';
if (Platform.OS === 'android') return 'android';
return undefined;
}
export async function fetchVersionInfo(
platformOverride?: 'ios' | 'android'
): Promise<VersionInfo> {
const platform = platformOverride || getPlatformParam();
const query = platform ? `?platform=${platform}` : '';
return await api.get<VersionInfo>(`/users/version-check${query}`);
}