Last active
July 27, 2020 22:48
-
-
Save elijahr/078bf89274eb54611faa1ecef98bc8cd to your computer and use it in GitHub Desktop.
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 | |
# A custom script which adds entries to LSApplicationQueriesScheme, for | |
# whitelisting application schemes that can be used to trigger FB/Instagram/etc | |
# shares. We can't use <config-file> directive in config.xml because | |
# cordova-plugin-facebook4 overwrites our custom values in the resulting | |
# *-Info.plist file. To add schemes to LSApplicationQueriesScheme, add | |
# them to the schemes array below. | |
# To enable this script, add hooks to your config.xml: | |
# | |
# <platform name="ios"> | |
# <hook src="path/to/whitelist-schemes.sh" type="after_prepare" /> | |
# <hook src="path/to/whitelist-schemes.sh" type="before_build" /> | |
# </platform> | |
# | |
# And change this to your app's name, whatever is between <name></name> in your config.xml: | |
app_name="StyleSeat" | |
# The app schemes that should be whitelisted | |
schemes=( | |
"fbapi" | |
"fb-messenger-api" | |
"fbauth2" | |
"fbshareextension" | |
"fb" | |
"twitter" | |
"instagram" | |
) | |
set -e | |
script=`basename "$0"` | |
phonegap_dir=$1 | |
function usage() { | |
echo "Usage: $script [path to phonegap directory]"; | |
} | |
if [ "$phonegap_dir" == "-h" ]; then | |
usage; | |
exit 0; | |
fi | |
if [ -z "$phonegap_dir" ]; then | |
usage; | |
exit 1; | |
fi | |
if [ ! -d "$phonegap_dir" ]; then | |
echo "Directory does not exist: $phonegap_dir" | |
usage; | |
exit 1; | |
fi | |
plist_path="${phonegap_dir}/platforms/ios/${app_name}/${app_name}-Info.plist" | |
echo "$script: whitelisting schemes in ${plist_path}" | |
/usr/libexec/PlistBuddy -c "Delete :LSApplicationQueriesSchemes" $plist_path || true | |
/usr/libexec/PlistBuddy -c "Add :LSApplicationQueriesSchemes array" $plist_path | |
for i in "${!schemes[@]}"; do | |
scheme="${schemes[$i]}" | |
/usr/libexec/PlistBuddy -c "Add :LSApplicationQueriesSchemes:$i string $scheme" $plist_path | |
echo "$script: whitelisted $scheme://" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment