hooks icon indicating copy to clipboard operation
hooks copied to clipboard

[Feat] Added deep linking hook

Open BenJeau opened this issue 5 years ago • 8 comments

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)?

  1. Have a React Native app
  2. Enable deep linking, for the android modifications
  3. 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)

BenJeau avatar Aug 10 '20 02:08 BenJeau

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?

pvinis avatar Aug 10 '20 09:08 pvinis

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

BenJeau avatar Aug 10 '20 11:08 BenJeau

Gotcha, then it sounds like a nice idea for here!

pvinis avatar Aug 10 '20 12:08 pvinis

React-navigation has this.

hosseinmd avatar Aug 20 '20 13:08 hosseinmd

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

BenJeau avatar Aug 21 '20 18:08 BenJeau

I don't think so, here is not a good place for this, that's good if you create PR to react-native-navigation.

hosseinmd avatar Aug 21 '20 19:08 hosseinmd

99% of software uses a navigation library. You get it right, this is useful, but the percentage of use is very low.

hosseinmd avatar Aug 21 '20 19:08 hosseinmd

@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.

BenJeau avatar Aug 21 '20 19:08 BenJeau

Closing as this does not seem of interest for the repository/package

BenJeau avatar Jan 30 '23 02:01 BenJeau