feat(fasting): 添加周期性断食计划功能
实现完整的周期性断食计划系统,支持每日自动续订和通知管理: - 新增周期性断食状态管理(activeCycle、currentCycleSession、cycleHistory) - 实现周期性断食会话的自动完成和续订逻辑 - 添加独立的周期性断食通知系统,避免与单次断食通知冲突 - 支持暂停/恢复周期性断食计划 - 添加周期性断食数据持久化和水合功能 - 优化断食界面,优先显示周期性断食信息 - 新增空状态引导界面,提升用户体验 - 保持单次断食功能向后兼容
This commit is contained in:
@@ -308,6 +308,13 @@ export class NotificationService {
|
||||
date: Date
|
||||
): Promise<string> {
|
||||
try {
|
||||
// 检查完整权限(系统权限 + 用户偏好)
|
||||
const hasPermission = await this.hasFullNotificationPermission();
|
||||
if (!hasPermission) {
|
||||
console.log('⚠️ 定时通知被系统权限或用户偏好设置阻止,跳过安排');
|
||||
return 'blocked_by_permission_or_preference';
|
||||
}
|
||||
|
||||
const notificationId = await Notifications.scheduleNotificationAsync({
|
||||
content: {
|
||||
title: notification.title,
|
||||
@@ -323,10 +330,10 @@ export class NotificationService {
|
||||
} as DateTrigger,
|
||||
});
|
||||
|
||||
console.log('定时通知已安排,ID:', notificationId);
|
||||
console.log('✅ 定时通知已安排,ID:', notificationId, '时间:', date.toLocaleString('zh-CN'));
|
||||
return notificationId;
|
||||
} catch (error) {
|
||||
console.error('安排定时通知失败:', error);
|
||||
console.error('❌ 安排定时通知失败:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user