hooks
hooks copied to clipboard
[Feat] Added deep linking hook
Summary
For the navigation library I use (react-native-navigation), there's no built-in support for deep linking, unlike react-navigation. Having a hook for the deep linking would be useful to simplify the use of deep links.
It uses
Linking.getInitialURL()function which return a promise with a string IF the application was fully closed- the Linking event listener on the 'url' type and gets triggered IF the application is in the foreground or background (not fully closed)
Test Plan
I've tested this on Android, in debug and release mode with react-native-navigation. I do not own a mac, so I did not test for iOS (but should work).
What's required for testing (prerequisites)?
- Have a React Native app
- Enable deep linking, for the android modifications
- Call the hook at the root of the application
What are the steps to reproduce (after prerequisites)?
To trigger the deep link, for android via adb step
Not exactly sure how to test it for iOS
Compatibility
| OS | Implemented |
|---|---|
| iOS | ✅ (should work, but not tested) |
| Android | ✅ |
| Web | ❌ |
Checklist
- [X] I have tested this on a device and a simulator
- [X] I added the documentation in
README.md - [X] I updated the typed files (TS and Flow)
- [ ] I've created a snack to demonstrate the changes (not exactly sure if deep linking can be shown with a snack, since you need to modify the native projects)
- [ ] For someone to test it with iOS (optional)
Have you thought of making this PR to react-native-navigation? I feel it would be more suited there. Here would be a secondary option.
What do you think?
I guess it could also be used for people who uses react-navigation or any other navigation library, but just want to do some custom logic around the deep linking (I was just saying how I would use it). The Linking API is something that is built in into React Native, and is not tied to a navigation library
Gotcha, then it sounds like a nice idea for here!
React-navigation has this.
Yes, react-navigation has built-in support for deep-linking, but not everyone is using that as a navigation library. react-native exposes the Linking API, and this is just creating a hook around that API - which may be useful if you don't use a navigation library like react-navigation that handles it built-in. It could even be useful with react-navigation if you want to do something special when the application is opened via a deep-link
I don't think so, here is not a good place for this, that's good if you create PR to react-native-navigation.
99% of software uses a navigation library. You get it right, this is useful, but the percentage of use is very low.
@hosseinmd even if the API is built-into react-native? This is just exposing a hook to another built-in react-native API just like the other hooks. But I guess if you think this won't be used/is useless, feel free to close it.
Closing as this does not seem of interest for the repository/package