我正在使用SwiftUI。
我想通过单击推送通知来打开除“根视图”之外的特定屏幕。 有多种使用StoryBoard打开它的方法,但并非没有StoryBoard。
不使用StoryBoard如何实现?
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
var window: UIWindow?
func userNotificationCenter(
_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions)
-> Void) {
completionHandler([.alert, .badge, .sound])
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void) {
// I want to open a screen other than Root View here.
completionHandler()
}
... }