From 42b6b2076c9cfec4247fdc2dab9035705b788fd2 Mon Sep 17 00:00:00 2001 From: richarjiang Date: Mon, 15 Sep 2025 19:28:13 +0800 Subject: [PATCH] fix --- app.json | 2 +- ios/digitalpilates/Info.plist | 2 +- services/backgroundTaskManager.ts | 25 ++++++++++++------------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/app.json b/app.json index 9d108dd..6a85bc1 100644 --- a/app.json +++ b/app.json @@ -2,7 +2,7 @@ "expo": { "name": "Out Live", "slug": "digital-pilates", - "version": "1.0.11", + "version": "1.0.12", "orientation": "portrait", "scheme": "digitalpilates", "userInterfaceStyle": "light", diff --git a/ios/digitalpilates/Info.plist b/ios/digitalpilates/Info.plist index d07ab55..349d87e 100644 --- a/ios/digitalpilates/Info.plist +++ b/ios/digitalpilates/Info.plist @@ -24,7 +24,7 @@ CFBundlePackageType $(PRODUCT_BUNDLE_PACKAGE_TYPE) CFBundleShortVersionString - 1.0.11 + 1.0.12 CFBundleSignature ???? CFBundleURLTypes diff --git a/services/backgroundTaskManager.ts b/services/backgroundTaskManager.ts index e1d0fb6..7b25fb7 100644 --- a/services/backgroundTaskManager.ts +++ b/services/backgroundTaskManager.ts @@ -1,25 +1,14 @@ import { store } from '@/store'; +import AsyncStorage from '@/utils/kvStore'; import { log } from '@/utils/logger'; import { StandReminderHelpers, WaterNotificationHelpers } from '@/utils/notificationHelpers'; -import AsyncStorage from '@/utils/kvStore'; import * as BackgroundTask from 'expo-background-task'; import * as TaskManager from 'expo-task-manager'; import { TaskManagerTaskBody } from 'expo-task-manager'; export const BACKGROUND_TASK_IDENTIFIER = 'com.anonymous.digitalpilates.task'; -// 定义后台任务 -TaskManager.defineTask(BACKGROUND_TASK_IDENTIFIER, async (body: TaskManagerTaskBody) => { - try { - log.info(`[BackgroundTask] 后台任务执行, 任务 ID: ${BACKGROUND_TASK_IDENTIFIER}`); - await executeBackgroundTasks(); - } catch (error) { - console.error('[BackgroundTask] 任务执行失败:', error); - return BackgroundTask.BackgroundTaskResult.Failed; - } - return BackgroundTask.BackgroundTaskResult.Success; -}); // 检查通知权限 async function checkNotificationPermissions(): Promise { @@ -191,8 +180,18 @@ export class BackgroundTaskManager { } try { + // 定义后台任务 + TaskManager.defineTask(BACKGROUND_TASK_IDENTIFIER, async (body: TaskManagerTaskBody) => { + try { + log.info(`[BackgroundTask] 后台任务执行, 任务 ID: ${BACKGROUND_TASK_IDENTIFIER}`); + await executeBackgroundTasks(); + } catch (error) { + console.error('[BackgroundTask] 任务执行失败:', error); + return BackgroundTask.BackgroundTaskResult.Failed; + } + return BackgroundTask.BackgroundTaskResult.Success; - + }); if (await TaskManager.isTaskRegisteredAsync(BACKGROUND_TASK_IDENTIFIER)) { log.info('[BackgroundTask] 任务已注册');