What you're asking about is called deep linking.
To open your native app from a browser:
- Your native app needs to define a URL
scheme that other apps can use to target it.
- Your browser-based code needs to redirect to a URL using your app's
scheme.
And, most likely:
- Your app needs a listener for the deep-link. If you don't write a listener, your app will open, but there would be no way for you to pass information into the app from your browser-based code.
Here is a crude example, as a starting point. I would encourage you to go read the docs thoroughly, because deep-linking is a lot more complicated than first glance. :)
React Native
First, create the my-excellent-app:// scheme for your app as explained here. If you're using Expo, this becomes even easier.
Then, add the listener as early as possible in the life-cycle. Like most of the documentation on this explains – usually in your top-most component in App.js or index.js.
import { Linking } from 'react-native';
import URL from 'url-parse';
// Make sure to only add this listener once!
// Adding it more than once will trigger the handler more than once. ;)
Linking.addEventListener('url', ({ url }) => {
const deeplink = URL(url, true);
console.log(deeplink.query);
});
Web-stuff
I'm not sure exactly what tech stack you're using, but the concept is simple enough: do whatever you need to do on the server, and then redirect the browser back to your app's custom scheme.
In Express, that would be something like:
res.redirect('my-excellent-app://myCustomLink?other=data&using=UrlParamsGoesHere');
Lastly, there are third parties like Branch that also handle quite a lot of this, and more.