NEW: Learn to build amazing SwiftUI apps for macOS with my new book! >>

CoreSpotlight and SwiftUI 2 - Deep linking with .onContinueUserActivity possible?

Forums > SwiftUI

Dear all,

I was following the implementation guidance of Spotlight of the Ultimate Portfolio App and tried to add search with Spotlight to my app as well.

I want to selected an item on Spotlight, navigate to the right detail view and perform an action based on the CSSearchableItemActionType.

However with .onContinueUserActivity I'm only able to perform this step by step, which means the following:

  1. I selected the Item in CoreSpotlight
  2. I get to the right TabView
  3. I selected the Item in CoreSpotlight again
  4. I get to the right DetailView of the TabView
  5. I selected the Item in CoreSpotlight again
  6. The right action gets performed on for the DetailView

This works but I want to perform all those steps with the first click on the Item on Spotlight (if I change back to a different TabView after Step 4 and select the Item in Spotlight again, I start with the first step again).

Each view has a .onContinueUserActivity: the initial AppView to get to the right TabView, the TabView to get to the right detail view, and the detail view to perform an action. I don't use any NavigationLinks in the respective Views.

  • Is there any possbility to chain all .onContinueUserActivity togehter, so they get performed in order once the user clicks on an Item in spotlight?
  • Or is a another approach needed to achieve something like this?

Any help is greatly appreaciated!

Cheers tobsens


Hacking with Swift is sponsored by RevenueCat

SPONSORED Spend less time managing in-app purchase infrastructure so you can focus on building your app. RevenueCat gives everything you need to easily implement, manage, and analyze in-app purchases and subscriptions without managing servers or writing backend code.

Get Started

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.