···11+//
22+// AppDelegate.swift
33+// AtProtoBackup
44+//
55+// Created by Corey Alexander on 8/29/25.
66+//
77+#if os(iOS)
88+import UIKit
99+1010+1111+class AppDelegate: NSObject, UIApplicationDelegate {
1212+ func application(_ application: UIApplication,
1313+ handleEventsForBackgroundURLSession identifier: String,
1414+ completionHandler: @escaping () -> Void) {
1515+ print("[AppDelegate] Handling background URLSession events for identifier: \(identifier)")
1616+1717+ // Note: We can't update Live Activities here because we don't have
1818+ // access to the download progress from the BlobDownloader.
1919+ // Live Activities will show stale data until the app returns to foreground.
2020+2121+ // Let BlobDownloader handle the completion
2222+ BlobDownloader.handleEventsForBackgroundURLSession(
2323+ identifier: identifier,
2424+ completionHandler: completionHandler
2525+ )
2626+ }
2727+2828+ func applicationDidEnterBackground(_ application: UIApplication) {
2929+ // Request background processing time
3030+ var backgroundTask: UIBackgroundTaskIdentifier = .invalid
3131+ backgroundTask = application.beginBackgroundTask {
3232+ application.endBackgroundTask(backgroundTask)
3333+ }
3434+3535+ // You get ~30 seconds to update Live Activities
3636+ Task {
3737+ // Note: We could update Live Activities here but we don't have
3838+ // access to current download progress. The DownloadManager would
3939+ // need to expose this data for background updates to work.
4040+ application.endBackgroundTask(backgroundTask)
4141+ }
4242+ }
4343+}
4444+#endif