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

Deep linking support #90

Closed
saurabhd opened this issue Nov 26, 2019 · 3 comments
Closed

Deep linking support #90

saurabhd opened this issue Nov 26, 2019 · 3 comments
Labels
✨ new feature New feature

Comments

@saurabhd
Copy link

saurabhd commented Nov 26, 2019

Is your feature request related to a problem? Please describe.
Providing a way for the deep linking support in the boilerplate code.

Describe the solution you'd like
I wanted to implement the deep linking support in the boilerplate. Therefore I made below adjustments in the code we have:

— Provided we have another screen available where we want to implement deep linking support.
— In the App/Navigators/AppNavigator.js file, we would need to define the screen name in the stack navigator. Along with that, we would need to supply path attribute to define a unique screen name as per the code segment below:

const StackNavigator = createStackNavigator(
    {
      SplashScreen: SplashScreen,
      MainScreen: {
        screen: ExampleScreen,
      },
      ChatScreen: {
        screen: ChatScreen,
        path: 'chat', // this attribute defines deep linking path
      },
  },
  {
    initialRouteName: 'SplashScreen',
    headerMode: 'none',
  }
)

— Then we would need to set the host in the App/Containers/Root/RootScreen.js and the same host needs to be set in the AppNavigator component props as per the code segment below:

render() {
    //Deep linking prefix
    const prefix = 'thecodingmachine://';

    return (
      <View style={styles.container}>
        <AppNavigator
          uriPrefix={prefix}
          // Initialize the NavigationService (see https://reactnavigation.org/docs/en/navigating-without-navigation-prop.html)
          ref={(navigatorRef) => {
            NavigationService.setTopLevelNavigator(navigatorRef)
          }}
        />
      </View>
    )
  }
}

— As a next step, we would need to set the host and scheme in Android manifest file. And for iOS, we would need to set the same in the Info tab in the xcodeproject.

Describe alternatives you've considered
— That was the simplest solution I could manage, but happy to explore and adapt the code.
@AurelGit - happy to prep this solution as PR if you think it will be fruitful. Thanks.

@AurelGit
Copy link
Collaborator

AurelGit commented Dec 4, 2019

Hey @saurabhd !

Sounds perfect :) We did it the same way on our projects, and it could be useful to have it in the boilerplate directly.

We will be very happy to have the PR :)

Thanks !

@saurabhd
Copy link
Author

saurabhd commented Dec 8, 2019

Hi @AurelGit - with regards to our discussions happened here, I am posting this PR. Thanks!

@AurelGit
Copy link
Collaborator

AurelGit commented Sep 2, 2020

See #112 😃

@AurelGit AurelGit closed this as completed Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ new feature New feature
Projects
None yet
Development

No branches or pull requests

2 participants