import UIKit // 应用委托:承载须在 launch 完成前注册、或经 UIKit 委托回调送达的平台集成——后台续传任务 // 注册(本文件),以及 APNs 远程通知的设备令牌回调(见扩展)。SwiftUI App 经 // @UIApplicationDelegateAdaptor 挂接。 final class AppDelegate: NSObject, UIApplicationDelegate { func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil ) -> Bool { // 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 能力后这里不会触发。 } }