I have a SwiftUI Apple Watch app. When a user taps on a complication, I want to show the appropriate view. I think I can do so with an onContinueUserActivity modifier but I can't find the appropriate ActivityType.
I named it CLKComplicationTapActivityType
below but I need the real constant.
struct ContentView: View {
var body: some View {
StationList()
.onContinueUserActivity(CLKComplicationTapActivityType, perform: handleComplicationTap)
}
func handleComplicationTap(_ userAcivity: NSUserActivity){
if let date = userAcivity.userInfo?[CLKLaunchedTimelineEntryDateKey]{
\\ handle the tap
}
}
}
See https://developer.apple.com/documentation/clockkit/clkcomplicationdescriptor/3612140-useractivity
You can define your own custom activity:
And then assign it to the
userActivity
property of theCLKComplicationDescriptor
that you return inCLKComplicationDataSource.getComplicationDescriptors(handler:)
.