In earlier watchOS versions (ver>9) we can use complication descriptor to add complications and metadata like userActivity for handle tap action in the watch app delegate (according to AppleDocs):
If you create a complication descriptor using the init(identifier:displayName:supportedFamilies:userActivity:) initializer to pass in an NSUserActivity object, when the user taps the corresponding complication, the system activates your app and passes the activity object to your onContinueUserActivity(_:perform:) modifiers.
But this "CLKComplicationDescriptor(identifier:displayName:supportedFamilies:userActivity:)" is using ClockKit and is deprecated now. I can't find any replacement for handling the tap event on new complications. I'm using watchOS 9 with Swift-UI. I want to do an action in my watch app when the user taps on my .accessoryCorner complication. I'm handling this behavior in my iOS app and widgets using .widgetURL(myUrl) and handling it in my SceneDelegate, but it does not work in the watch.
Use the
.widgetURL
modifier in your action widget. When tapped, this will launch your watch app and theonOpenURL()
method receives the url included in the.widgetURL