feat(workout): 新增锻炼结束监听和个性化通知功能
实现了iOS HealthKit锻炼数据实时监听,当用户完成锻炼时自动发送个性化鼓励通知。包括锻炼类型筛选、时间范围控制、用户偏好设置等完整功能,并提供了测试工具和详细文档。
This commit is contained in:
@@ -13,6 +13,7 @@ import { notificationService } from '@/services/notifications';
|
||||
import { setupQuickActions } from '@/services/quickActions';
|
||||
import { initializeWaterRecordBridge } from '@/services/waterRecordBridge';
|
||||
import { WaterRecordSource } from '@/services/waterRecords';
|
||||
import { workoutMonitorService } from '@/services/workoutMonitor';
|
||||
import { store } from '@/store';
|
||||
import { fetchMyProfile, setPrivacyAgreed } from '@/store/userSlice';
|
||||
import { createWaterRecordAction } from '@/store/waterSlice';
|
||||
@@ -102,6 +103,18 @@ function Bootstrapper({ children }: { children: React.ReactNode }) {
|
||||
initializeWaterRecordBridge();
|
||||
console.log('喝水记录 Bridge 初始化成功');
|
||||
|
||||
// 初始化锻炼监听服务
|
||||
const initializeWorkoutMonitoring = async () => {
|
||||
try {
|
||||
await workoutMonitorService.initialize();
|
||||
console.log('锻炼监听服务初始化成功');
|
||||
} catch (error) {
|
||||
console.warn('锻炼监听服务初始化失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
initializeWorkoutMonitoring();
|
||||
|
||||
// 检查并同步Widget数据更改
|
||||
const widgetSync = await syncPendingWidgetChanges();
|
||||
if (widgetSync.hasPendingChanges && widgetSync.pendingRecords) {
|
||||
@@ -204,6 +217,7 @@ export default function RootLayout() {
|
||||
<Stack.Screen name="article/[id]" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="water-detail" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="water-settings" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="workout/notification-settings" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="+not-found" />
|
||||
</Stack>
|
||||
<StatusBar style="dark" />
|
||||
|
||||
Reference in New Issue
Block a user