1212using UnityEditor . Build ;
1313using UnityEditor ;
1414using UnityEngine ;
15+ using System . Reflection ;
1516
1617// Warning: Don't use #if #endif for conditional compilation here as Unity
1718// doesn't always set the flags early enough.
@@ -419,7 +420,21 @@ private static void OnPostprocessInfo(PlistDocumentWrapper info, AppCenterSettin
419420 {
420421 if ( settings . UseDistribute && AppCenter . Distribute != null )
421422 {
422- // Add App Center URL sceme.
423+ // Add App Center URL scemes.
424+ var schemes = new List < string > ( ) { "appcenter-" + settings . iOSAppSecret } ;
425+
426+ // Create a reflection call for getting custom schemes from iOS settings.
427+ var playerSettingsClass = typeof ( PlayerSettings . iOS ) ;
428+ var iOSURLSchemesMethod = playerSettingsClass . GetMethod ( "GetURLSchemes" , BindingFlags . Static | BindingFlags . NonPublic ) ;
429+
430+ // Verify that method exists and call it for getting custom schemes.
431+ if ( iOSURLSchemesMethod != null )
432+ {
433+ var schemesFromSettings = ( string [ ] ) iOSURLSchemesMethod . Invoke ( null , null ) ;
434+ schemes . AddRange ( schemesFromSettings . ToList < string > ( ) ) ;
435+ }
436+
437+ // Generate scheme information.
423438 var root = info . GetRoot ( ) ;
424439 var urlTypes = root . GetType ( ) . GetMethod ( "CreateArray" ) . Invoke ( root , new object [ ] { "CFBundleURLTypes" } ) ;
425440 if ( settings . UseDistribute && AppCenter . Distribute != null )
@@ -429,7 +444,12 @@ private static void OnPostprocessInfo(PlistDocumentWrapper info, AppCenterSettin
429444 setStringMethod . Invoke ( urlType , new object [ ] { "CFBundleTypeRole" , "None" } ) ;
430445 setStringMethod . Invoke ( urlType , new object [ ] { "CFBundleURLName" , ApplicationIdHelper . GetApplicationId ( ) } ) ;
431446 var urlSchemes = urlType . GetType ( ) . GetMethod ( "CreateArray" ) . Invoke ( urlType , new [ ] { "CFBundleURLSchemes" } ) ;
432- urlSchemes . GetType ( ) . GetMethod ( "AddString" ) . Invoke ( urlSchemes , new [ ] { "appcenter-" + settings . iOSAppSecret } ) ;
447+
448+ // Add custom schemes defined in Unity players settings.
449+ foreach ( var scheme in schemes )
450+ {
451+ urlSchemes . GetType ( ) . GetMethod ( "AddString" ) . Invoke ( urlSchemes , new [ ] { scheme } ) ;
452+ }
433453 }
434454 }
435455 }
0 commit comments