watchOS SwiftUI application deeplink on push notifications

Hey,

I am currently trying to add deeplink handling from tapping on push notifications in my watchOS application with a SwiftUI lifecycle.

I already have deeplinking working with several onOpenURL modifiers throughout the app for the iOS version. What I wanted to do, is whenever I receive a push notification I construct an URL and then utilise the onOpenURL view modifier to handle the deeplink.

I currently struggle to understand if this is possible at all.

I have the following setup

@main
struct WatchApp: App {

    @WKApplicationDelegateAdaptor var appDelegate: WatchAppDelegate

    // MARK: - Body
    var body: some Scene {
        WindowGroup {
           ContentView()
        }
    }
}
class WatchAppDelegate: NSObject, WKApplicationDelegate, ObservableObject {

    func applicationDidFinishLaunching() {
        UNUserNotificationCenter.current().delegate = self
    }
}

extension WatchAppDelegate: UNUserNotificationCenterDelegate {

    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
    // handle the push notification 
    }
}

I do receive the the notification as expected in userNotificationCenter(center:, didReceive:) but from there on I didn't find a way bring this information into my app. On iOS I do leverage UIApplication.shared.open(url:) but this is obviously not available on watchOS.

What is the official guidance of handling watchOS deep links with SwiftUI lifecycle from tapping of push notifications ?

Currently the onOpenURL modifiers are placed on several views, so it would be nice if there is a way to trigger them from a central place.

Would be really appreciated if someone knows a way on how to do it :)

watchOS SwiftUI application deeplink on push notifications
 
 
Q