I am new to Swift and have been using SwiftUI, not Storyboard.
I set the UIApplicationShortcutItems in the Info.plist and have two quick actions that are able to present an alert with launchOptions.
I am able to switch-case out the quick actions in SceneDelegate.swift
func windowScene(_ windowScene: UIWindowScene, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
switch shortcutItem.type {
case "QuickAction1":
OneView() // What do I do to open this SwiftUI struct View?
break
case "QuickAction2":
SecondView() // What do I do to open this SwiftUI struct View?
break
default:
break
}
}
What is the proper way to open a particular view from a home quick action using SwiftUI?
ContentView.swift
struct ContentView: View {
var body: some View {
NavigationView {
VStack {
NavigationLink(destination: OneView())
NavigationLink(destination: TwoView())
}
}
}
}
Here is possible approach by steps (tested with Xcode 11.2 / iOS 13.2)
AppSettingsclass to store mode of views to be presented by shorcutappSettingsscene delegate member to access it and inContentViewand in shortcut delegate and pass it inContentViewas environment objectContentViewpresent links conditionally based on selected shortcut mode