I'd like pressing a notification to open up a certain page in the SwiftUI app. I'm able to trigger the print statement "notification was tapped" when the notification is tapped by having this code in the AppDelegate.swift
extension AppDelegate: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert, .sound, .badge])
}
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
print("notification was tapped")
// add code to open specific swiftUI view here!
completionHandler()
}
}
How can control the view that will be opened from the AppDelegate.swift?