Refactor iOS dependencies and update HealthKit integration
- Removed NitroModules and ReactNativeHealthkit from Podfile.lock and package files. - Updated Info.plist to increment app version from 2 to 3. - Refactored background task manager to define background tasks within the class. - Added new utility file for sleep data management, including fetching sleep samples, calculating sleep statistics, and generating sleep quality scores.
This commit is contained in:
@@ -8,17 +8,6 @@ import { TaskManagerTaskBody } from 'expo-task-manager';
|
||||
const BACKGROUND_TASK_IDENTIFIER = 'background-task';
|
||||
|
||||
|
||||
// 定义后台任务
|
||||
TaskManager.defineTask(BACKGROUND_TASK_IDENTIFIER, async (body: TaskManagerTaskBody) => {
|
||||
try {
|
||||
console.log('[BackgroundTask] 后台任务执行');
|
||||
await executeBackgroundTasks();
|
||||
return BackgroundTask.BackgroundTaskResult.Success;
|
||||
} catch (error) {
|
||||
console.error('[BackgroundTask] 任务执行失败:', error);
|
||||
return BackgroundTask.BackgroundTaskResult.Failed;
|
||||
}
|
||||
});
|
||||
|
||||
// 检查通知权限
|
||||
async function checkNotificationPermissions(): Promise<boolean> {
|
||||
@@ -201,6 +190,20 @@ export class BackgroundTaskManager {
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
// 定义后台任务
|
||||
TaskManager.defineTask(BACKGROUND_TASK_IDENTIFIER, async (body: TaskManagerTaskBody) => {
|
||||
try {
|
||||
console.log('[BackgroundTask] 后台任务执行');
|
||||
await executeBackgroundTasks();
|
||||
return BackgroundTask.BackgroundTaskResult.Success;
|
||||
} catch (error) {
|
||||
console.error('[BackgroundTask] 任务执行失败:', error);
|
||||
return BackgroundTask.BackgroundTaskResult.Failed;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 注册后台任务
|
||||
const status = await BackgroundTask.registerTaskAsync(BACKGROUND_TASK_IDENTIFIER, {
|
||||
minimumInterval: 15,
|
||||
|
||||
Reference in New Issue
Block a user