0

I have a very simple app flow. ParentVC and ChildVC. In the ParentVC, I have a collection view and on its didSelectItem, the ChildVC opens up with the relative content. Now I have used iOS 14 WidgetKit to create Small & Medium size widgets which when app goes to background, stores the PageTitle of of the ChildVC and shows that on the WidgetUI.

My requirement is: How can I open that particular ChildVC when I tap on the Widget?

PS: I am using AppDelegate and not SceneDelegate.

zeytin
  • 5,545
  • 4
  • 14
  • 38
  • Does this answer your question? [Perform a deeplink from SwiftUI widget on tap](https://stackoverflow.com/questions/64230355/perform-a-deeplink-from-swiftui-widget-on-tap) – pawello2222 Nov 20 '20 at 11:37

1 Answers1

0

Add the following function to your Appdelegate:

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    let vcNext = UIStoryboard(name: "nameYourStoryBoard", bundle: nil).instantiateViewController(withIdentifier: "IdentifierOfViewController") as! YourViewController
    let tabbar = window?.rootViewController as? UITabBarController

    let navcontrol = tabbar?.selectedViewController as? UINavigationController
    navcontrol?.pushViewController(vcNext, animated: true)
    window?.makeKeyAndVisible()
   return true
}