1
votes

My initial view controller is a tab bar controller, in the tab controller there are several UINavigationControllers, in one of the UINavigationControllers a modal is presented where another UINavigationController is created with another flow of UIViewControllers.

I need to respond to a received remote notification in the App Delegate by pushing to one of the “deepest” parts of that view hierarchy.

I can recreate a UINavigationController and launch the proper UIViewController by name, however it leaves the user high and dry with no other place to go.

Is there a way to get the user back into the proper flow of navigation?

1

1 Answers

4
votes

The way I got this to work, in the didReceiveRemoteNotification method of my App Delegate:

let rootTabbarController = self.window?.rootViewController as UITabBarController

let mainStoryboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)

let firstNavigationController = mainStoryboard.instantiateViewControllerWithIdentifier("firstNavVc") as UINavigationController

rootTabbarController.viewControllers![0] = firstNavigationController

let vControllerForFirstNavController = (rootTabbarController.viewControllers![0] as UINavigationController).topViewController as MainViewController

let firstDetailsNavController = mainStoryboard.instantiateViewControllerWithIdentifier("detailsNavController") as MainDetailsMenuNavigationController

let detailsVc = firstDetailsNavController.topViewController as MainDetailsViewController

firstNavigationController.presentViewController(firstDetailsNavController, animated: false, completion: nil)

let specificInfoVc = mainStoryboard.instantiateViewControllerWithIdentifier("sDetails") as SpecificDetailsViewController

firstDetailsNavController.pushViewController(specificInfoVc, animated: true)