From 303c36025b9f0e80c64cd5c5228d25c64d98122a Mon Sep 17 00:00:00 2001 From: richarjiang Date: Wed, 1 Oct 2025 22:59:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/backgroundTaskManager.ts | 36 ++++--------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/services/backgroundTaskManager.ts b/services/backgroundTaskManager.ts index 5bcbfdc..fb2d0a2 100644 --- a/services/backgroundTaskManager.ts +++ b/services/backgroundTaskManager.ts @@ -1,14 +1,14 @@ +import { listChallenges } from '@/services/challengesApi'; import { store } from '@/store'; +import { getWaterIntakeFromHealthKit } from '@/utils/health'; import AsyncStorage from '@/utils/kvStore'; import { log } from '@/utils/logger'; -import { listChallenges } from '@/services/challengesApi'; -import { ChallengeNotificationHelpers, StandReminderHelpers, WaterNotificationHelpers } from '@/utils/notificationHelpers'; -import { getWaterIntakeFromHealthKit } from '@/utils/health'; +import { ChallengeNotificationHelpers, WaterNotificationHelpers } from '@/utils/notificationHelpers'; import { getWaterGoalFromStorage } from '@/utils/userPreferences'; +import dayjs from 'dayjs'; import * as BackgroundTask from 'expo-background-task'; import * as TaskManager from 'expo-task-manager'; import { TaskManagerTaskBody } from 'expo-task-manager'; -import dayjs from 'dayjs'; export const BACKGROUND_TASK_IDENTIFIER = 'com.anonymous.digitalpilates.task'; @@ -107,34 +107,6 @@ async function executeWaterReminderTask(): Promise { } } -// 执行站立提醒后台任务 -async function executeStandReminderTask(): Promise { - try { - console.log('执行站立提醒后台任务...'); - - // 获取当前状态 - const state = store.getState(); - const userProfile = state.user.profile; - - // 获取用户名 - const userName = userProfile?.name || '朋友'; - - // 调用站立提醒检查函数 - const notificationSent = await StandReminderHelpers.checkStandStatusAndNotify(userName); - - if (notificationSent) { - console.log('后台站立提醒通知已发送'); - // 记录后台任务执行时间 - await AsyncStorage.setItem('@last_background_stand_check', Date.now().toString()); - } else { - console.log('无需发送后台站立提醒通知'); - } - - } catch (error) { - console.error('执行站立提醒后台任务失败:', error); - } -} - async function executeChallengeReminderTask(): Promise { try { console.log('执行挑战鼓励提醒后台任务...');