feat(medications): 重构药品通知系统并添加独立设置页面
- 创建药品通知服务模块,统一管理药品提醒通知的调度和取消 - 新增独立的通知设置页面,支持总开关和药品提醒开关分离控制 - 重构药品详情页面,移除频率编辑功能到独立页面 - 优化药品添加流程,支持拍照和相册选择图片 - 改进通知权限检查和错误处理机制 - 更新用户偏好设置,添加药品提醒开关配置
This commit is contained in:
@@ -204,6 +204,11 @@ export class NotificationService {
|
||||
console.log('用户点击了锻炼完成通知', data);
|
||||
// 跳转到锻炼历史页面
|
||||
router.push('/workout/history' as any);
|
||||
} else if (data?.type === NotificationTypes.MEDICATION_REMINDER) {
|
||||
// 处理药品提醒通知
|
||||
console.log('用户点击了药品提醒通知', data);
|
||||
// 跳转到药品页面
|
||||
router.push('/(tabs)/medications' as any);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,6 +543,7 @@ export const NotificationTypes = {
|
||||
WORKOUT_COMPLETION: 'workout_completion',
|
||||
FASTING_START: 'fasting_start',
|
||||
FASTING_END: 'fasting_end',
|
||||
MEDICATION_REMINDER: 'medication_reminder',
|
||||
} as const;
|
||||
|
||||
// 便捷方法
|
||||
@@ -574,3 +580,22 @@ export const sendMoodCheckinReminder = (title: string, body: string, date?: Date
|
||||
return notificationService.sendImmediateNotification(notification);
|
||||
}
|
||||
};
|
||||
|
||||
export const sendMedicationReminder = (title: string, body: string, medicationId?: string, date?: Date) => {
|
||||
const notification: NotificationData = {
|
||||
title,
|
||||
body,
|
||||
data: {
|
||||
type: NotificationTypes.MEDICATION_REMINDER,
|
||||
medicationId: medicationId || ''
|
||||
},
|
||||
sound: true,
|
||||
priority: 'high',
|
||||
};
|
||||
|
||||
if (date) {
|
||||
return notificationService.scheduleNotificationAtDate(notification, date);
|
||||
} else {
|
||||
return notificationService.sendImmediateNotification(notification);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user