Last active
March 22, 2021 22:00
-
-
Save sezabass/945eadc4deb3bdc910002b1865fb8fc1 to your computer and use it in GitHub Desktop.
Open DeepLink helper for testing apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# USAGE (make sure to use quotes when setting URI) | |
# ./openDeepLink.sh -u "your://deeplink?with=some_param&another=param" | |
# When using an Android emulator, use "-e" option | |
# ./openDeepLink.sh -e -u "your://deeplink" | |
# For iOS, use "-i" option | |
#./openDeepLink.sh -i -u "your://ios?deeplink=here" | |
while getopts "ieu:" opt; do | |
case ${opt} in | |
i) arg_ios="1" ;; | |
e) arg_emulator="1" ;; | |
u) arg_uri="$OPTARG" ;; | |
\?) echo "Invalid option -$OPTARG" >&2; exit ;; | |
esac | |
done | |
deepLink () { | |
if [ -z "${arg_emulator}" ]; then | |
emulator="" | |
else | |
emulator="-s emulator-5554" | |
fi | |
if [ -z "${arg_uri}" ]; then | |
#### CHANGE THIS! #### | |
uri="yourscheme://your-default-hostname" | |
else | |
uri=${arg_uri} | |
fi | |
if [ -z "${arg_ios}" ]; then | |
# shellcheck disable=SC2086 | |
adb ${emulator} shell am start -a 'android.intent.action.VIEW' -d "\"${uri}\"" | |
else | |
xcrun simctl openurl booted "${uri}" | |
fi | |
} | |
deepLink |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you just have one function you don't need to hard code it.
The shell allows you to use the $@. It's a bit smarter.