It is possible via the new AppIntents framework to open your app from via a shortcuts intent, but I am currently very confused about how to ensure that a particular window is opened in a SwiftUI-runtime app.
If the use says "Open View A" via a shortcuts, or Siri, I'd like to make sure it opens the window for "View A", though a duplicate window could be acceptable too.
The WWDC22 presentation has the following:
@MainActor
func perform() async throws -> some IntentResult {
Navigator.shared.openShelf(.currentlyReading)
return .result()
}
Where, from the perform method of the Intent structure, they tell an arbitrary Navigator (code not provided) to just open a view of the app. (How convenient!)
But for a multiwindow swiftUI app, I'm not sure how to make this work. @Environment
variables are not available within the Intent struct, and even if I did have a "Navigator Singleton", I'm not sure how it could get the @Environment
for openWindow
since it's a View environment. AppIntents exist outside the View environment tree AFAIK.
Any Ideas? I'd be a little shocked if this is a UIKit only sort of thing, but at the same time... ya never know.