feat(notifications): 新增晚餐和心情提醒功能,支持HRV压力检测和后台处理
- 新增晚餐提醒(18:00)和心情提醒(21:00)的定时通知 - 实现基于HRV数据的压力检测和智能鼓励通知 - 添加后台任务处理支持,修改iOS后台模式为processing - 优化营养记录页面使用Redux状态管理,支持实时数据更新 - 重构卡路里计算公式,移除目标卡路里概念,改为基代+运动-饮食 - 新增营养目标动态计算功能,基于用户身体数据智能推荐 - 完善通知点击跳转逻辑,支持多种提醒类型的路由处理
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import * as Notifications from 'expo-notifications';
|
||||
import { router } from 'expo-router';
|
||||
|
||||
// 配置通知处理方式
|
||||
Notifications.setNotificationHandler({
|
||||
@@ -133,6 +134,8 @@ export class NotificationService {
|
||||
const { notification } = response;
|
||||
const data = notification.request.content.data;
|
||||
|
||||
console.log('处理通知点击:', data);
|
||||
|
||||
// 根据通知类型处理不同的逻辑
|
||||
if (data?.type === 'workout_reminder') {
|
||||
// 处理运动提醒
|
||||
@@ -150,8 +153,24 @@ export class NotificationService {
|
||||
} else if (data?.type === 'lunch_reminder') {
|
||||
// 处理午餐提醒通知
|
||||
console.log('用户点击了午餐提醒通知', data);
|
||||
// 这里可以添加导航到午餐记录页面的逻辑
|
||||
|
||||
// 跳转到营养记录页面
|
||||
if (data?.url) {
|
||||
router.push(data.url as any);
|
||||
}
|
||||
} else if (data?.type === 'dinner_reminder') {
|
||||
// 处理晚餐提醒通知
|
||||
console.log('用户点击了晚餐提醒通知', data);
|
||||
// 跳转到营养记录页面
|
||||
if (data?.url) {
|
||||
router.push(data.url as any);
|
||||
}
|
||||
} else if (data?.type === 'mood_reminder') {
|
||||
// 处理心情提醒通知
|
||||
console.log('用户点击了心情提醒通知', data);
|
||||
// 跳转到心情页面
|
||||
if (data?.url) {
|
||||
router.push(data.url as any);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,6 +445,8 @@ export const NotificationTypes = {
|
||||
NUTRITION_REMINDER: 'nutrition_reminder',
|
||||
PROGRESS_UPDATE: 'progress_update',
|
||||
LUNCH_REMINDER: 'lunch_reminder',
|
||||
DINNER_REMINDER: 'dinner_reminder',
|
||||
MOOD_REMINDER: 'mood_reminder',
|
||||
} as const;
|
||||
|
||||
// 便捷方法
|
||||
|
||||
Reference in New Issue
Block a user