feat: 添加后台任务管理器,支持喝水和站立提醒功能
This commit is contained in:
@@ -527,6 +527,8 @@ export default function ExploreScreen() {
|
||||
}
|
||||
}, [todayWaterStats, userProfile]);
|
||||
|
||||
|
||||
|
||||
// 日期点击时,加载对应日期数据
|
||||
const onSelectDate = React.useCallback((index: number, date: Date) => {
|
||||
setSelectedIndex(index);
|
||||
@@ -1082,4 +1084,5 @@ const styles = StyleSheet.create({
|
||||
padding: 4,
|
||||
},
|
||||
|
||||
|
||||
});
|
||||
|
||||
@@ -12,6 +12,7 @@ import { notificationService } from '@/services/notifications';
|
||||
import { store } from '@/store';
|
||||
import { rehydrateUser, setPrivacyAgreed } from '@/store/userSlice';
|
||||
import { MoodNotificationHelpers, NutritionNotificationHelpers } from '@/utils/notificationHelpers';
|
||||
import { backgroundTaskManager } from '@/services/backgroundTaskManager';
|
||||
import React from 'react';
|
||||
import RNExitApp from 'react-native-exit-app';
|
||||
|
||||
@@ -35,8 +36,12 @@ function Bootstrapper({ children }: { children: React.ReactNode }) {
|
||||
// 初始化通知服务
|
||||
await notificationService.initialize();
|
||||
console.log('通知服务初始化成功');
|
||||
|
||||
// 初始化后台任务管理器
|
||||
await backgroundTaskManager.initialize();
|
||||
console.log('后台任务管理器初始化成功');
|
||||
} catch (error) {
|
||||
console.error('通知服务初始化失败:', error);
|
||||
console.error('通知服务或后台任务管理器初始化失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -71,6 +76,10 @@ function Bootstrapper({ children }: { children: React.ReactNode }) {
|
||||
// 注册心情提醒(21:00)
|
||||
await MoodNotificationHelpers.scheduleDailyMoodReminder(profile.name);
|
||||
console.log('心情提醒已注册');
|
||||
|
||||
// 注册喝水提醒后台任务
|
||||
await backgroundTaskManager.registerWaterReminderTask();
|
||||
console.log('喝水提醒后台任务已注册');
|
||||
} catch (error) {
|
||||
console.error('注册提醒失败:', error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user