28
28
29
29
public class TwitterPostProcessBuild {
30
30
31
+ private const string URL_TYPES = "CFBundleURLTypes" ;
32
+ private const string URL_SCHEMES = "CFBundleURLSchemes" ;
33
+ private const string APPLICATION_QUERIES_SCHEMES = "LSApplicationQueriesSchemes" ;
34
+
31
35
[ PostProcessBuild ]
32
36
public static void UpdateXCodePlist ( BuildTarget buildTarget , string pathToBuiltProject ) {
33
37
#if UNITY_IOS
@@ -48,11 +52,17 @@ public static void UpdateXCodePlist(BuildTarget buildTarget, string pathToBuiltP
48
52
PlistElementDict rootDict = plist . root ;
49
53
50
54
// Modify Info.Plist for Twitter Kit (https://dev.twitter.com/twitterkit/ios/installation)
51
- PlistElementArray bundleURLTypesArray = rootDict . CreateArray ( "CFBundleURLTypes" ) ;
55
+ PlistElementArray bundleURLTypesArray = rootDict [ URL_TYPES ] as PlistElementArray ;
56
+ if ( bundleURLTypesArray == null ) {
57
+ bundleURLTypesArray = rootDict . CreateArray ( URL_TYPES ) ;
58
+ }
52
59
PlistElementDict dict = bundleURLTypesArray . AddDict ( ) ;
53
- PlistElementArray bundleURLSchemesArray = dict . CreateArray ( "CFBundleURLSchemes" ) ;
60
+ PlistElementArray bundleURLSchemesArray = dict . CreateArray ( URL_SCHEMES ) ;
54
61
bundleURLSchemesArray . AddString ( "twitterkit-" + TwitterSettings . ConsumerKey ) ;
55
- PlistElementArray queriesSchemesArray = rootDict . CreateArray ( "LSApplicationQueriesSchemes" ) ;
62
+ PlistElementArray queriesSchemesArray = rootDict [ APPLICATION_QUERIES_SCHEMES ] as PlistElementArray ;
63
+ if ( queriesSchemesArray == null ) {
64
+ queriesSchemesArray = rootDict . CreateArray ( APPLICATION_QUERIES_SCHEMES ) ;
65
+ }
56
66
queriesSchemesArray . AddString ( "twitter" ) ;
57
67
queriesSchemesArray . AddString ( "twitterauth" ) ;
58
68
0 commit comments