On Continue User Activity with Swift UI

Hi All, I'm very new to iOS development and Swift UI is my first coding language. I'm trying to link the users search results in Spotlight with the detail view that is stored in Core Data. I can search for users data in spotlight but when I tap on it, it's only appearing in the main view of the app. Is there anyways that I can use .onContinueUserActivity at the launch of the app or is there any different code that I have to use? I've searched for many articles but I couldn't get a solution. It would be good if anyone can share some links or guide here. Thank you.

.onContinueUserActivity(DetailView.productUserActivityType) { userActivity in

            if let product = try? userActivity.typedPayload(Product.self) {

                selectedProduct = product.id.uuidString

            }

        }

I get this code from Apple's State restoration app but I can't use this with Core Data.

On Continue User Activity with Swift UI
 
 
Q