import UIKit import UserNotifications class AppDelegate: NSObject, UIApplicationDelegate { func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil ) -> Bool { // On-device crash/hang diagnostics. Nothing is uploaded anywhere: reports // stay in the app container and Apple's own pipeline is what feeds the // Xcode Organizer. See DiagnosticsCollector. DiagnosticsCollector.shared.start() // Request notification permissions requestNotificationPermissions() // Apple Watch bridge: activating early means the first application // context lands before the user raises their wrist. Task { @MainActor in WatchSyncService.shared.activate() } return true } private func requestNotificationPermissions() { let center = UNUserNotificationCenter.current() center.requestAuthorization(options: [.alert, .badge, .sound]) { granted, error in if let error = error { print("Notification permission error: \(error)") } print("Notification permission granted: \(granted)") } } func application( _ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data ) { let token = deviceToken.map { String(format: "%02.2hhx", $0) }.joined() print("Device token: \(token)") } func application( _ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error ) { print("Failed to register for remote notifications: \(error)") } }