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 Additions and Parameter Parsing #2609

Merged
merged 6 commits into from
Nov 9, 2017

Conversation

jwh70
Copy link
Contributor

@jwh70 jwh70 commented Nov 9, 2017

Universal Linking with Parameter Parsing

  • First of all, love the library and the work you guys are doing!
  • Saw the most recent pull request Deep linking #2148 to support deep linking (which is awesome!) and I'd like to propose some additions that would allow for both deep linking and universal linking with url parameter parsing.
  • Often, the use case for deep/universal linking is to mirror a uri pattern that exists on the web, not just a deep link to a native app. With libraries like React Router, we can express our path schema with syntax from a widely accepted URI standard (https://tools.ietf.org/html/rfc6570). We should be able to parse urls like this in RNRF too!
  • Beyond just handling a deep link with RNRF, we certainly need to be able to parse url parameters and pass those params to our deeply linked scene, especially if we otherwise assume that the given scene's component will always be routed to with params.

Use Case

  • Consider a web app and mobile app pairing for a social network, which might have a url https://thesocialnetwork.com/profile/1234/.
  • If we were building both a web app and a mobile app, we'd like to be able to express that uri scheme across platforms with the path /profile/:id/.
  • On the web, we might want React-Router to to open up our <Profile /> component with the props { id: 1234 }.
  • On mobile, if we've correctly set up our Android/iOS environment to launch our application and open our RNRF <Router />, then we also want to navigate to our mobile <Profile /> scene with the params { id: 1234 }

This PR Includes

Usage

  • Very similar to the recently merged in spec, this allows for the same exact syntax. One can declare a Router such as:
<Router uriPrefix={'thesocialnetwork.com'}>
  <Scene key="root">
     <Scene key={'home'} component={Home} />
     <Scene key={'profile'} path={"/profile/:id/"} component={Profile} />
     <Scene key={'profileForm'} path={"/edit/profile/:id/"} component={ProfileForm} />
  </Scene>
</Router>

If a user clicks on http://thesocialnetwork.com/profile/1234/ on their device, they'll open the <Router /> and then call Actions.profile({ id: 1234 })

@jwh70 jwh70 changed the title Feature/universal linking Deep Linking Additions with Parameter Parsing Nov 9, 2017
@jwh70 jwh70 changed the title Deep Linking Additions with Parameter Parsing Deep Linking Additions and Parameter Parsing Nov 9, 2017
@aksonov
Copy link
Owner

aksonov commented Nov 9, 2017

LGTM, good job! Could you also add your great use case/usage to docs?

@aksonov aksonov merged commit d1d4e87 into aksonov:master Nov 9, 2017
@jwh70
Copy link
Contributor Author

jwh70 commented Nov 9, 2017

yes can have a pr with docs later today!

mvanroon pushed a commit to mvanroon/react-native-router-flux that referenced this pull request Feb 15, 2018
* Adds universal linking with parameter parsing

* Adds universal linking with parameter parsing

* Adds universal linking with parameter parsing

* yarn lock

* linting

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

Successfully merging this pull request may close these issues.

2 participants