feat(app): 启用Expo Updates自动更新功能,优化医疗记录上传流程与API集成
This commit is contained in:
@@ -1,14 +1,7 @@
|
||||
import '@/i18n';
|
||||
import { DefaultTheme, ThemeProvider } from '@react-navigation/native';
|
||||
import { useFonts } from 'expo-font';
|
||||
import { Stack, useRouter } from 'expo-router';
|
||||
import { StatusBar } from 'expo-status-bar';
|
||||
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
||||
import 'react-native-reanimated';
|
||||
|
||||
import PrivacyConsentModal from '@/components/PrivacyConsentModal';
|
||||
import { useAppDispatch, useAppSelector } from '@/hooks/redux';
|
||||
import { useQuickActions } from '@/hooks/useQuickActions';
|
||||
import '@/i18n';
|
||||
import { hrvMonitorService } from '@/services/hrvMonitor';
|
||||
import { cleanupLegacyMedicationNotifications } from '@/services/medicationNotificationCleanup';
|
||||
import { clearBadgeCount, notificationService } from '@/services/notifications';
|
||||
@@ -26,8 +19,15 @@ import { initializeHealthPermissions } from '@/utils/health';
|
||||
import { MoodNotificationHelpers, NutritionNotificationHelpers, WaterNotificationHelpers } from '@/utils/notificationHelpers';
|
||||
import { getMoodReminderEnabled, getNutritionReminderEnabled, getWaterReminderSettings } from '@/utils/userPreferences';
|
||||
import { clearPendingWaterRecords, syncPendingWidgetChanges } from '@/utils/widgetDataSync';
|
||||
import { DefaultTheme, ThemeProvider } from '@react-navigation/native';
|
||||
import { useFonts } from 'expo-font';
|
||||
import { Stack, useRouter } from 'expo-router';
|
||||
import { StatusBar } from 'expo-status-bar';
|
||||
import * as Updates from 'expo-updates';
|
||||
import React, { useEffect } from 'react';
|
||||
import { AppState, AppStateStatus } from 'react-native';
|
||||
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
||||
import 'react-native-reanimated';
|
||||
|
||||
import { DialogProvider } from '@/components/ui/DialogProvider';
|
||||
import { MembershipModalProvider } from '@/contexts/MembershipModalContext';
|
||||
@@ -485,6 +485,31 @@ function Bootstrapper({ children }: { children: React.ReactNode }) {
|
||||
getPrivacyAgreed();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
async function checkUpdate() {
|
||||
try {
|
||||
logger.info("Checking for updates...");
|
||||
const update = await Updates.checkForUpdateAsync();
|
||||
logger.info("Update check:", update);
|
||||
|
||||
if (update.isAvailable) {
|
||||
logger.info("Update available, fetching...");
|
||||
const result = await Updates.fetchUpdateAsync();
|
||||
logger.info("Fetch result:", result);
|
||||
|
||||
if (result.isNew) {
|
||||
logger.info("Reloading app to apply update...");
|
||||
Updates.reloadAsync();
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error("Update error:", e);
|
||||
}
|
||||
}
|
||||
|
||||
checkUpdate();
|
||||
}, []);
|
||||
|
||||
const handlePrivacyAgree = () => {
|
||||
dispatch(setPrivacyAgreed());
|
||||
setShowPrivacyModal(false);
|
||||
|
||||
Reference in New Issue
Block a user