Files
suixinkan_ios_new/suixinkan/App/AppDelegate.swift
汉秋 be9c844bd3 将 otg_swift OTG 引擎迁入 Core/CameraOTG,并接入旅拍有线传图与历史导入。
恢复 USB 相机连接、边拍边传、三品牌驱动与 SwiftUI 历史导入页,通过适配层对接现有本地上传与 OSS 管道。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 11:22:07 +08:00

94 lines
2.9 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// AppDelegate.swift
// suixinkan
//
// Created by Codex on 2026/6/26.
//
import UIKit
/// AppDelegate APNs SDK SwiftUI App adaptor
final class AppDelegate: NSObject, UIApplicationDelegate {
/// SwiftUI UIKit `delegate.window`
@objc var window: UIWindow?
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
syncKeyWindow()
NotificationCenter.default.addObserver(
self,
selector: #selector(syncKeyWindow),
name: UIWindow.didBecomeKeyNotification,
object: nil
)
Task { @MainActor in
WeChatManager.shared.registerIfNeeded()
}
return true
}
/// `window` key window UIKit / SDK AppDelegate
@objc private func syncKeyWindow() {
window = UIApplication.shared.connectedScenes
.compactMap { $0 as? UIWindowScene }
.flatMap(\.windows)
.first(where: \.isKeyWindow)
}
func application(
_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
) -> Bool {
MainActor.assumeIsolated {
WeChatManager.shared.handleOpenURL(url)
}
}
func application(
_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
) -> Bool {
MainActor.assumeIsolated {
WeChatManager.shared.handleContinueUserActivity(userActivity)
}
}
func application(
_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
) {
Task { @MainActor in
PushNotificationManager.shared.handleDeviceToken(deviceToken)
}
}
func application(
_ application: UIApplication,
didFailToRegisterForRemoteNotificationsWithError error: Error
) {
Task { @MainActor in
PushNotificationManager.shared.handleRegistrationError(error)
}
}
func application(
_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void
) {
let payload = PushPayload(userInfo: userInfo)
Task { @MainActor in
PushNotificationManager.shared.handleRemoteNotification(payload)
completionHandler(.newData)
}
}
func applicationWillTerminate(_ application: UIApplication) {
ConnectionManager.shared.disconnect()
}
}