import UIKit import UserNotifications final class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate { func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil, ) -> Bool { UNUserNotificationCenter.current().delegate = self return true } func application( _ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data, ) { PushNotificationManager.shared.didRegisterForRemoteNotifications(deviceToken: deviceToken) } func application( _ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error, ) { PushNotificationManager.shared.didFailToRegisterForRemoteNotifications(error: error) } func application( _ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], ) async -> UIBackgroundFetchResult { await PushNotificationManager.shared.handleRemoteNotification(userInfo: userInfo) return .newData } func userNotificationCenter( _ center: UNUserNotificationCenter, willPresent notification: UNNotification, ) async -> UNNotificationPresentationOptions { await PushNotificationManager.shared.handleRemoteNotification(userInfo: notification.request.content.userInfo) return [.banner, .badge, .sound] } func userNotificationCenter( _ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, ) async { await PushNotificationManager.shared.handleNotificationTap(userInfo: response.notification.request.content.userInfo) } }