forked from ionic-team/ionic-package-hooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ios9_allow_native_whatsapp.sh
executable file
·44 lines (37 loc) · 1.2 KB
/
ios9_allow_native_whatsapp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
if [[ ! -f /usr/libexec/PlistBuddy ]]; then
exit 0
fi
PLIST=platforms/ios/*/*-Info.plist
APPLICATION='whatsapp' # The application we want to add
# Adds the application with new LSApplicationQueriesSchemes array
function AddApplicationWithNewArray {
cat << EOF | # Bypass ATS for test servers
Add :LSApplicationQueriesSchemes array
Add :LSApplicationQueriesSchemes:0 string $APPLICATION
EOF
while read line
do
/usr/libexec/PlistBuddy -c "$line" $PLIST
done
}
# Adds the application without new LSApplicationQueriesSchemes array
function AddApplicationWithoutNewArray {
cat << EOF | # Bypass ATS for test servers
Add :LSApplicationQueriesSchemes:0 string $APPLICATION
EOF
while read line
do
/usr/libexec/PlistBuddy -c "$line" $PLIST
done
}
val=$(/usr/libexec/PlistBuddy -x -c 'print ":LSApplicationQueriesSchemes"' $PLIST 2>/dev/null)
exitCode=$?
if [ "$exitCode" -eq "0" ] # Found the LSApplicationQueriesSchemes element, add just the application
then
if [[ ! "$val" =~ "<string>$APPLICATION</string>" ]]; then # If the application does not exist
AddApplicationWithoutNewArray
fi
else # Didn't find LSApplicationQueriesSchemesKey element, add the element with the application
AddApplicationWithNewArray
fi