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)
}
}