349d94aa8f
- 原生数据面 libwebrtc(PLAN 决策 F):新增 Engine/LibWebRtcEngine.swift(RTCPeerConnection,端口 engine.go/session.go 线协议 + 水位背压 + ack 完成 + 不冲突落盘);NativeTransfer.swift 的 P2PEventsBridge 改 conform P2PEngineDelegate(去 gomobile);EngineController 4 个 p2p RPC 改调新引擎(completion-based + resolveOnMain)。stasel/WebRTC M149 经 SPM(exactVersion 149.0.0)。环回端到端 20MB 逐字节测过(Tests/) - UX 改造(PARITY 残余项 1/2):新增 SendComposeSheet(发送预览=文件名 + 选设备,手动多选与分享共用);分享直入预览 + scenePhase .active 兜底(修“分享后必须重启 app”);重写 MessagesView(按设备会话 + 每设备未读红点 + 删单条 / 删整设备历史);EngineController 加 conversations / unread 模型 - 品牌 logo:新增 Shared/Brand.swift(BrandMark / Wordmark / BrandLockup / BrandHero)+ Brand.xcassets/LogoMark;登录页 / 传输空态 / 设置头 / 控制中心控件接 logo;Theme 加 cdropAmber - 字体(对齐 web,仅主 app):新增 BrandFonts.swift(Orbit Gothic + Maple Mono woff2 运行期 CTFontManager 注册 + UIKit 外观代理 + .oXxx / .maple 助手);Fredoka SemiBold 字标;7 视图 .font sweep。字体不入库——.gitignore 排除 + just ios-fonts 构建前从 CDN / Google Fonts 拉取,见 Sources/Fonts/README.md - 分享引导:新增 Share/ShareGuideView(吉祥物卡 + “打开 Commilitia Drop”);ShareViewController 健壮 staging(文件 / 数据双路)+ 响应链 IMP 唤起宿主 - 全平台平均速度:传输完成态显平均速度(总字节 / 总耗时)而非末次瞬时——web store/slices/transfer.ts + TransferRow.tsx + iOS RootView 卡片 / 详情;i18n 加 transfer.avgRate - 工程:project.yml 接 SPM WebRTC + CDropTests + Fredoka UIAppFonts + Share i18n;Justfile 加 ios-sim-build + ios-fonts / ios-fonts-fredoka 配方 - 文档:ios/PLAN.md(决策 F + §10 UX + §11 品牌/字体 + §12 平均速度)、ios/PARITY.md(字体分叉条目更新 + 2026-06-28 漂移行)
74 lines
3.5 KiB
Swift
74 lines
3.5 KiB
Swift
import UIKit
|
||
|
||
// 应用委托:承载须在 launch 完成前注册、或经 UIKit 委托回调送达的平台集成——后台续传任务
|
||
// 注册(本文件),以及 APNs 远程通知的设备令牌回调(见扩展)。SwiftUI App 经
|
||
// @UIApplicationDelegateAdaptor 挂接。
|
||
final class AppDelegate: NSObject, UIApplicationDelegate
|
||
{
|
||
func application(
|
||
_ application: UIApplication,
|
||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
|
||
) -> Bool
|
||
{
|
||
// 品牌字体须在任何 UI 渲染前注册 + 设外观代理(导航 / 标签栏标题换 Orbit Gothic)。
|
||
BrandFonts.register()
|
||
// BGContinuedProcessingTask 的 launch handler 须在 launch 完成前注册。
|
||
BackgroundTaskManager.shared.registerOnce()
|
||
return true
|
||
}
|
||
|
||
// APNs 注册成功:拿到设备令牌 → 交 PushRegistry 经引擎桥上报后端。
|
||
func application(
|
||
_ application: UIApplication,
|
||
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
|
||
)
|
||
{
|
||
PushRegistry.shared.didRegister(tokenData: deviceToken)
|
||
}
|
||
|
||
// APNs 注册失败(模拟器无 APNs 支撑 / 未配能力 / 无网络):退化为仅在线 SSE 收事件,非致命。
|
||
func application(
|
||
_ application: UIApplication,
|
||
didFailToRegisterForRemoteNotificationsWithError error: Error
|
||
)
|
||
{
|
||
// 仅记录,不打断。真机配齐 Push 能力后这里不会触发。
|
||
}
|
||
|
||
// content-available 推送的「短暂后台唤醒」(服务端有消息时触发,见 apns/sender.go):在 ~30s 后台
|
||
// 窗口内只做隔离的控件 / 剪贴板会话保活——刷新其自身 access,使关闭 / 墓碑态下的剪贴板保持可用。
|
||
// 刻意不触碰引擎主会话(主会话由引擎独占续期;后台刷新它会与挂起引擎的内存令牌失同步而触发重登,
|
||
// 即 #7)。不维持持续连接:仅此一次短暂处理后即让系统挂起。
|
||
func application(
|
||
_ application: UIApplication,
|
||
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
|
||
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void
|
||
)
|
||
{
|
||
// 被其他设备登出(session:revoked 推送):立即清本地登录态——Keychain 主会话 + 控件会话——
|
||
// 并通知前台 UI 回登录页。前台 / 后台 / 关闭态皆据此清:后台关闭态清 Keychain 即下次启动为登出态,
|
||
// 前台则经 NotificationCenter 即时回登录页。不必等下次请求 401 才发现。
|
||
// 与后端 push.KindSessionRevoked 一致(Go 侧常量值)。
|
||
if (userInfo["type"] as? String) == "session:revoked"
|
||
{
|
||
AuthManager.clearPersistedSession()
|
||
WidgetSessionStore.clear()
|
||
NotificationCenter.default.post(name: .cdropSessionRevoked, object: nil)
|
||
completionHandler(.newData)
|
||
return
|
||
}
|
||
// content-available 后台唤醒:刷新隔离的控件会话(剪贴板保活),不碰引擎主会话(避免 #7)。
|
||
Task
|
||
{
|
||
await WidgetSessionStore.refreshAccess()
|
||
completionHandler(.newData)
|
||
}
|
||
}
|
||
}
|
||
|
||
extension Notification.Name
|
||
{
|
||
// 被其他设备登出的推送到达:UI 层据此立即回登录页(见 AppRoot.onReceive)。
|
||
static let cdropSessionRevoked = Notification.Name("cdrop.sessionRevoked")
|
||
}
|