how to use a 3D short cut with the totally closed application

I'm soliciting you because I'm having a problem using the 3D short cut for my ios application in uikit in the AppDelegate file but it's impossible to redirect the route when the user has completely killed the application. It works as a background application. I'd like it to redirect to the searchPage search page when the application is fully closed and the user clicks on search with 3D touch.

final class AppDelegate: UIResponder, UIApplicationDelegate {
    lazy var window: UIWindow? = {
        return UIWindow(frame: UIScreen.main.bounds)
    }()

 private let appDependencyContainer = Container()
    private let disposeBag = DisposeBag()
    var pendingDeeplink: String?

    private lazy var onboardingNavigationController: UINavigationController = {
        let navigationController = UINavigationController(nibName: nil, bundle: nil)
        navigationController.setNavigationBarHidden(true, animated: false)
       return navigationController
    }()



private func handleShortcutItem(_ shortcutItem: UIApplicationShortcutItem) {
            guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
                  let window = windowScene.windows.first(where: { $0.isKeyWindow }),
                  let rootVC = window.rootViewController else {
                DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { [weak self] in
                    self?.handleShortcutItem(shortcutItem)
                }
                return
            }

            if let presentedVC = rootVC.presentedViewController {
                presentedVC.dismiss(animated: !UIAccessibility.isReduceMotionEnabled) { [weak self] in
                    self?.executeShortcutNavigation(shortcutItem)
                }
            } else {
                executeShortcutNavigation(shortcutItem)
            }
        }

    private func executeShortcutNavigation(_ shortcutItem: UIApplicationShortcutItem) {
        DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [weak self] in
            guard let self = self else { return }

            switch shortcutItem.type {
            case ShortcutType.searchAction.rawValue:
                self.mainRouter.drive(to: .searchPage(.show), origin: AppRoutingOrigin())
            case ShortcutType.playAction.rawValue:
                self.mainRouter.drive(to: .live(channel: Channel(), appTabOrigin: AppTabOrigin.navigation.rawValue), origin: AppRoutingOrigin())
            case ShortcutType.myListHistoryAction.rawValue:
                self.mainRouter.drive(to: .myList(.history), origin: AppRoutingOrigin())
            default:
                break
            }
        }
    }

What I've tried:

Adding delays with DispatchQueue.main.asyncAfter

Checking for window availability and rootViewController

Dismissing presented view controllers before navigation

Environment:

iOS 15+

Swift 6

Using custom router system (mainRouter)

App supports both SwiftUI and UIKit

Questions:

What's the best practice for handling shortcuts on cold launch vs warm launch?

How can I ensure the router is properly initialized before navigation?

how to use a 3D short cut with the totally closed application
 
 
Q