Add APNs push notification registration and payload routing.
Introduce AppDelegate, explicit Info.plist and entitlements, and wire PushNotificationManager into login lifecycle for device token upload and notification handling. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
41
suixinkan/App/AppDelegate.swift
Normal file
41
suixinkan/App/AppDelegate.swift
Normal file
@ -0,0 +1,41 @@
|
||||
//
|
||||
// AppDelegate.swift
|
||||
// suixinkan
|
||||
//
|
||||
// Created by Codex on 2026/6/26.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
/// AppDelegate 承接 APNs 系统回调,SwiftUI App 入口通过 adaptor 注入。
|
||||
final class AppDelegate: NSObject, UIApplicationDelegate {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user