I am building a SwiftUI app, and I want to navigate to a specific view when a custom action is triggered from the Control Center. I need to handle this action and programmatically navigate to a particular screen in my app.
I am already using NavigationStack in my project, but I couldn’t figure out how to integrate this behavior with Control Center actions.
How can I detect and handle this type of event and navigate to the desired view?
I tried using UIApplication.shared.open(URL) to trigger a specific URL scheme that navigates to the desired view. I also added a deep link configuration in the Info.plist file and registered custom URL schemes.
However, when I test it from Control Center, the app opens but does not navigate to the desired view. Instead, it always shows the default screen.
I expected the app to open directly to the specified view when the URL scheme is triggered.
Wincent is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.