Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Construct navigation stack #35

Closed
corysullivan opened this issue Nov 6, 2016 · 2 comments
Closed

Construct navigation stack #35

corysullivan opened this issue Nov 6, 2016 · 2 comments
Labels

Comments

@corysullivan
Copy link

When opening the app from a deeplink that references a viewcontroller that is 2, 3.. views deep in a UINavigationController stack, how do you build up the stack? In the included repo example if you do a cold start from safari using navigator://user/devxoul url, the user can never get back to the user list.

@devxoul
Copy link
Owner

devxoul commented Nov 6, 2016

@Sully73, you should map both URLNavigable and URLOpenHandler to navigator://user/<username>. Use open() in cold-start to construct navigation stack and use push() or present() in navigating between view controllers.

Navigator.map("navigator://user/<username>", UserViewController.self)
Navigator.map("navigator://user/<username>") { url, values in
  gurad let userViewController = Navigator.viewController(for: url) as? UserViewController else {
    return false
  }
  constructNavigationStack(with: userViewController) // your custom function
}
func application(
  _ application: UIApplication,
  didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -> Bool {
  if let url = launchOptions?[.url] as? URL {
    Navigator.open(url) // use `open()`
  }
  return true
}

@corysullivan
Copy link
Author

Great thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants