Open view deep in NavigationView from push notification

Hi,

I want to open a view after taping on a push notification. The views and notifications are all working fine but my problem is when I try to open the view from the push notification via .sheet(isPresented) it is always presenting the view as modal.

I would like to achieve that the view is actually opened embedded in the NavigationView it would usually be when accessing it manually.

To make it more clear:

Code Block
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView{
VStack{
NavigationLink(destination: ListView()){
Text("Going one level down")
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct ListView: View {
var body: some View{
NavigationLink(destination: DetailView()){
Text("Click me")
}
}
}
struct DetailView: View {
var body: some View{
Text("I want to display this view after tapping on a notification.")
}
}


After tapping on the push notification, I want to jump directly to the DetailView() down in the NavigationView tree (similar to what the Apple Calendar app is doing when you tap on the notification).

Any ideas? :)

Max
  • @bobandsee did you find the answer to this? I have the same issue and I can't really find anything regarding SwiftUI to handle this.

Add a Comment