acorn icon indicating copy to clipboard operation
acorn copied to clipboard

Deep linking

Open nhaarman opened this issue 6 years ago • 2 comments

Related to #4

It should be possible to deep link into an application, for example to navigate directly to a product detail page.

nhaarman avatar Aug 16 '18 10:08 nhaarman

This can be done by either

  • Having a different Activity with its own Navigator handle the Intent in a completely separate task;
  • Wrapping the 'main' Navigator in another Navigator (like CompositeStackNavigator) and push the new Navigator on it.

nhaarman avatar Sep 25 '18 18:09 nhaarman

This can be done by either

* Having a different Activity with its own Navigator handle the Intent in a completely separate task;

* Wrapping the 'main' Navigator in another Navigator (like `CompositeStackNavigator`) and push the new Navigator on it.

Is the document ready (even draft is fine)?

I am writing integration test (using espresso) to test navigation between scenes. For example, create deep link: (skip splash scene ->) login scene -> register scene, and start with register scene first, then test press back will navigate back to login scene.

Here is how I try to create deep link by providing another NavigatorProvider with pre-defined NavigatorState.

object : AbstractNavigatorProvider<MainNavigator>() {
  override fun createNavigator(savedState: NavigatorState?): MainNavigator {
    return MainNavigator(navigatorState { state ->
      state["navigator:class"] = AuthNavigator::class.java.name
      state["navigator:state"] = navigatorState { navState ->
        navState["size"] = 2
        navState["0_class"] = LoginScene::class.java.name
        navState["1_class"] = RegisterScene::class.java.name
      }
    })
  }
}

And I know it looks like a hack, but I don't know how to create another navigator to wrap the 'main' Navigator that I want to test.

VincentJian avatar May 27 '20 07:05 VincentJian