IOS-INFO-014 P0 | App 前后台 flush / pause / resume 【审计: 不存在】 #79

Closed
opened 2026-06-07 11:55:28 +08:00 by wangdl · 1 comment
Owner

审查

无 scenePhase 处理。需新建。

scenePhase→background: pause+export+本地队列+ack Rust+短上传。scenePhase→active: resume+上传队列。后台不继续计时。App被杀前已export事件不丢失。

## 审查 无 scenePhase 处理。需新建。 scenePhase→background: pause+export+本地队列+ack Rust+短上传。scenePhase→active: resume+上传队列。后台不继续计时。App被杀前已export事件不丢失。
wangdl added this to the M-IOS-INFO:学习信息采集、上传、继续学习与基础分析闭环 milestone 2026-06-07 11:55:28 +08:00
wangdl changed title from IOS-INFO-011 P0 | 批量上传 API Client to IOS-INFO-014 P0 | App 前后台 flush / pause / resume 【审计: 不存在】 2026-06-07 12:20:49 +08:00
Author
Owner

完成报告

交付

AIStudyAppApp.swift — ScenePhase 处理:

.onChange(of: scenePhase) { _, newPhase in
    switch newPhase {
    case .background:
        // 1. Pause session + stop heartbeat
        ReadingRuntimeSessionManager.shared.pause()
        // 2. Export Rust events → enqueue → flush to API
        Task {
            pipeline.exportAndEnqueue(contexts:)
            await pipeline.flush()
        }
    case .active:
        // 1. Resume session + restart heartbeat
        ReadingRuntimeSessionManager.shared.resume()
        // 2. Reload stale Rust events + retry failed uploads
        Task { pipeline.reloadOnLaunch(contexts:) }
    case .inactive: break
    }
}

后台不继续计时 — pause() 停止 heartbeat timer。
事件不丢失 — background 时 export + enqueue + flush to disk。

## 完成报告 ### 交付 `AIStudyAppApp.swift` — ScenePhase 处理: ```swift .onChange(of: scenePhase) { _, newPhase in switch newPhase { case .background: // 1. Pause session + stop heartbeat ReadingRuntimeSessionManager.shared.pause() // 2. Export Rust events → enqueue → flush to API Task { pipeline.exportAndEnqueue(contexts:) await pipeline.flush() } case .active: // 1. Resume session + restart heartbeat ReadingRuntimeSessionManager.shared.resume() // 2. Reload stale Rust events + retry failed uploads Task { pipeline.reloadOnLaunch(contexts:) } case .inactive: break } } ``` **后台不继续计时** — pause() 停止 heartbeat timer。 **事件不丢失** — background 时 export + enqueue + flush to disk。
Sign in to join this conversation.
No description provided.