iOS UILocalNotification 启动特定屏幕

iOS UILocalNotification launch specific screen

我正在尝试在用户点击 UILocalNotification 时使用特定屏幕启动我的应用程序。这是我在 AppDelegate:

中的代码
 // MARK: - Local Notification
        func application(_ application: UIApplication, didReceive notification: UILocalNotification)
        {
            if (application.applicationState == UIApplicationState.active)
            {
                print("Active")
            }
            else if (application.applicationState == UIApplicationState.background)
            {
                print("Background")
            }
            else if (application.applicationState == UIApplicationState.inactive)
            {
                print("Inactive")
                print(notification.userInfo as Any)
                self.redirectToPage(userInfo: notification.userInfo as! [String : String])
            }
        }

        func redirectToPage(userInfo: [String : String]!)
        {
            if userInfo != nil
            {
                if let pageType = userInfo["TYPE"]
                {
                    if pageType == "Page1"
                    {
                        let storyboard = UIStoryboard(name: "Main", bundle: nil)
                        self.window?.rootViewController = storyboard.instantiateViewController(withIdentifier: "promoVC")
                    }
                }
            }
        }

当应用程序处于后台或非活动状态时它工作正常,但当它被暂停时,点击 UILocalNotification 以默认屏幕启动应用程序。当我的应用程序处于暂停状态时,如何在特定屏幕上启动我的应用程序?

在 didFinishLaunching 中完成所有操作,因为这是暂停应用程序通知的来源

例如

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]?) -> Bool {
        //allow notifs
        let types : UIUserNotificationType = [.alert]
        let settings = UIUserNotificationSettings(types: types, categories: nil)
        application.registerUserNotificationSettings(settings)

        //forward notif, if any
        if let note = launchOptions?[UIApplicationLaunchOptionsKey.localNotification] as? UILocalNotification {
            handleNotification(note: note, fromLaunch: true)
        }
}

 func application(_ application: UIApplication, didReceive note: UILocalNotification) {
            handleNotification(note: note, fromLaunch: false)
 }

 func handleNotification(note:UILocalNotification, launch:Bool) {
       if (application.applicationState == UIApplicationState.active)
        {
            print("Active")
        }
        else if (application.applicationState == UIApplicationState.background)
        {
            print("Background")
        }
        else if (application.applicationState == UIApplicationState.inactive)
        {
            print("Inactive")
            print(notification.userInfo as Any)
            self.redirectToPage(userInfo: notification.userInfo as! [String : String])
        }
        else {
            print("other ;)")
            print(notification.userInfo as Any)
            self.redirectToPage(userInfo: notification.userInfo as! [String : String])
        }

    }