SwiftUI: UNUserNotificationCenter delegate not called on cold start when opening notification

I'm sending local push notifications and want to show specific content based on the id of any notification the user opens. I'm able to do this with no issues when the app is already running in the background using the code below.

final class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate {

    let container = AppContainer()

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
        let center = UNUserNotificationCenter.current()
        center.delegate = self
        return true
    }
    
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler:  () -> Void) {
        container.notifications.handleResponse(response)
        completionHandler()
    }
}

However, the delegate never fires if the app was terminated before the user taps the notification. I'm looking for a way to fix this without switching my app lifecycle to UIKit.

This is a SwiftUI lifecycle app using UIApplicationDelegateAdaptor.

@main
struct MyApp: App {
     @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

     var body: some Scene {
         WindowGroup {
             ContentView()
        }
    }
}

I’m aware notification responses may be delivered via launchOptions on cold start, but I’m unsure how to bridge that cleanly into a SwiftUI lifecycle app without reverting to UIKit.

SwiftUI: UNUserNotificationCenter delegate not called on cold start when opening notification
 
 
Q