A small web server to test deep linking functionality on React Native apps.
Deep linking on iOS is called Universal Links and on Android is called App Links. Both are a way to open a specific screen in your app from a link in a web page or email.
This project is a small web server that can be used to test deep linking on your React Native app. It is a simple Express server that serves a few simple pages and redirects. When you click on the link, it will open your app and navigate to the screen you want.
nvm use
yarn install
edit /etc/hosts
# Deep link sandbox
127.0.0.1 deep-link-sandbox.local
127.0.0.1 deep-link-sandbox-intercept.local
# End of deep link sandbox
edit app.js
to set hostedDomain
.
edit public/index.html
to set the hostedDomains.
DEBUG=deep-link-sandbox:* yarn start
open http://deep-link-sandbox.local
It seems like the iOS .well-known/apple-app-site-association
file needs to be served over a secure connection.
So, you'll need to create this file and upload it to a server that supports HTTPS. This should be the same domain as used in app.js
and public/index.html
.
You also need to go to the Apple developer website https://developer.apple.com and make sure the app supports Associated Domains
.
Lastly, you need to configure your local app in XCode to support the domain. Go to Signing & Capabilities
and add the domain to Associated Domains
.
Similar to iOS, you need to create a .well-known/assetlinks.json
file and upload it to a server that supports HTTPS. This should be the same domain as used in app.js
and public/index.html
.
Use keytool -list -v -keystore android/app/debug.keystore
to get the SHA256 fingerprint used in assetlinks.json
.
You may be able to edit the Android hosts file with something like the following.
Lines to add
10.0.2.2 deep-link-sandbox.local
10.0.2.2 deep-link-sandbox-intercept.local
The following was only done once and it seemed kind of inconsistent, so it's worth trying it / restarting to see what works. It seems to keep the hosts edits if opened from the command line, but not if opened from Android Studio. If you go back to Android Studio, they are gone and then command line and they are there.
# This leaves the emulator open in a tab, which is different than how react native normally launches the emulator.
emulator -writable-system @Pixel_3a_API_33_x86_64
adb root
adb shell avbctl disable-verification
adb reboot
adb root
adb remount
adb pull /etc/hosts
# edit `hosts`
adb push ./local.file /remote-location
adb reboot