Friday, March 22, 2024
HomeiOS Developmentios - Open NavigationLink from Native Notification in NavigationStack iOS17

ios – Open NavigationLink from Native Notification in NavigationStack iOS17


The Notification offers the uuid akin to the Merchandise saved in SwiftData.

Objective is to open the proper DetailItem View once I faucet the notification.
How can I obtain this?

@Mannequin
last class Merchandise {
    @Attribute(.distinctive) var uuid: UUID
     ...
}

extension LocalNotificationManager: UNUserNotificationCenterDelegate {


func userNotificationCenter(_ middle: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
    
    guard let userInfo = response.notification.request.content material.userInfo["uuid"] as? Knowledge else {
        print("No information present in notification userInfo")
        return
    }
    **What shall I do right here ?**
    
}

struct ItemList: View {
@Question var objects: [Item]
@State personal var path = NavigationPath()

var physique: some View {
    NavigationStack(path: $path) {
                ForEach(Array(objects.enumerated()), id: .factor.id) { index, merchandise in
                    NavigationLink(worth: merchandise) {
                        ItemButton(merchandise: merchandise, index: index)
                        }
                    }
                }
        }.navigationDestination(for: Merchandise.self) { merchandise in
            DetailItem(merchandise: merchandise)
        }
 }



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments