コード例 #1
0
 private void SaveData()
 {
     _config.DisplayName = _displayName;
     _config.SteamId     = _steamId;
     ConfigurationStorage.Save(_config);
     _config = null;
 }
コード例 #2
0
        private static void UpdateManifest(AppLinkingConfiguration configuration, string pathToBuiltProject)
        {
            var projPath = Path.Combine(pathToBuiltProject, Application.productName);

            var manifest = Path.Combine(projPath, "Package.appxmanifest");

            var elem = XElement.Load(manifest);

            //new XAttribute("xmlns:uap3", "http://schemas.microsoft.com/appx/manifest/uap/windows10/3")

            var domain = configuration.GetPlatformDomainProtocols(SupportedPlatforms.UWP, true);

            if (domain.Count != 0)
            {
                HandleNamespaceRegistration(elem);
            }

            var apps = GetElement(elem, "Applications");
            var app  = GetElement(apps, "Application");

            var extensions = GetElement(app, "Extensions");

            if (extensions == null)
            {
                app.Add(extensions = CreateChild(app, "Extensions"));
            }

            RemoveOldRegistrations(extensions);

            AddDeepLinkConfiguration(configuration, elem, extensions);
            AddDomainAssociationConfiguration(configuration, elem, extensions);

            elem.Save(manifest);
        }
コード例 #3
0
        private static void AddDeepLinkConfiguration(AppLinkingConfiguration configuration, XElement elem, XElement extensions)
        {
            var config = configuration.GetPlatformDeepLinkingProtocols(SupportedPlatforms.UWP, true);

            if (config.Count == 0)
            {
                return;
            }

            var uapPrefix = elem.GetNamespaceOfPrefix("uap");

            foreach (var deepLink in config)
            {
                var extension = new XElement(uapPrefix + "Extension", new XAttribute(CategoryAttr, WinProtocol));
                extensions.Add(extension);

                var protocol = new XElement(uapPrefix + "Protocol", new XAttribute("Name", deepLink.Scheme));
                extension.Add(protocol);

                var logo = new XElement(uapPrefix + "Logo")
                {
                    Value = @"Assets\StoreLogo.png"
                };
                var displayName = new XElement(uapPrefix + "DisplayName")
                {
                    Value = string.IsNullOrEmpty(configuration.DisplayName)
                        ? Application.productName
                        : configuration.DisplayName
                };

                protocol.Add(logo);
                protocol.Add(displayName);
            }
        }
コード例 #4
0
        private void AddDeepLinks(AppLinkingConfiguration configuration, string pathToBuiltProject)
        {
#if UDL_DEBUG
            Debug.Log("UDL: Adding deep links");
#endif
            string plistPath;
            var    plist = GetPlistFile(pathToBuiltProject, out plistPath);


            var rootDict = plist.root;

            var bgModes = rootDict.CreateArray("CFBundleURLTypes");

            foreach (var deepLinkingProtocol in configuration.GetPlatformDeepLinkingProtocols(SupportedPlatforms.OSX, true))
            {
                var dict = bgModes.AddDict();

                dict.SetString("CFBundleTypeRole", "Viewer");

                dict.SetString("CFBundleURLIconFile", "Logo");

                dict.SetString("CFBundleURLName", Application.identifier);

                dict.CreateArray("CFBundleURLSchemes").AddString(deepLinkingProtocol.Scheme);
            }


            File.WriteAllText(plistPath, plist.WriteToString());
        }
コード例 #5
0
        public void PostBuildProcess(AppLinkingConfiguration configuration, string pathToBuiltProject)
        {
            ChangeIOSFlagsAndFrameworks(pathToBuiltProject);

            AddDeepLinks(configuration, pathToBuiltProject);

            AddDomainAssociation(pathToBuiltProject, configuration);
        }
コード例 #6
0
        private void ChangeEntitlementAssociatedDomains(string entitlementFilePath, AppLinkingConfiguration configuration)
        {
            PlistDocument entitlementFile = new PlistDocument();

            entitlementFile.ReadFromString(File.ReadAllText(entitlementFilePath));

            PlistElementDict rootElement = entitlementFile.root;


            var mtarget = _target == BuildTarget.iOS ? SupportedPlatforms.iOS : SupportedPlatforms.tvOS;

            var configs = configuration.GetPlatformDomainProtocols(mtarget, true).Select(d => d.Host)
                          .Distinct().ToArray();

            if (configs.Length != 0)
            {
                var associatedDomainsArrayElement = rootElement[AssociatedDomainsKey] as PlistElementArray;

                var alreadySetupDomains = new string[0];
                if (associatedDomainsArrayElement == null)
                {
                    associatedDomainsArrayElement = rootElement.CreateArray(AssociatedDomainsKey);
                }
                else
                {
                    try
                    {
                        alreadySetupDomains = associatedDomainsArrayElement.values.Select(a => a.AsString()).ToArray();
                    }
                    catch (Exception e)
                    {
                    }
                }



                //
                //  The except removes any config when the Append is used in the generation
                //
                foreach (var domainProtocol in configs.Where(c => alreadySetupDomains.Any(d => d.Contains(c)) == false))
                {
                    associatedDomainsArrayElement.AddString(AppLinksKey + domainProtocol);
                }
            }
            else
            {
                if (rootElement.values.ContainsKey(AssociatedDomainsKey))
                {
                    rootElement.values.Remove(AssociatedDomainsKey);
                }
            }


            File.WriteAllText(entitlementFilePath, entitlementFile.WriteToString());
        }
コード例 #7
0
        public static void Save(AppLinkingConfiguration config)
        {
#if DEBUG
            var data = JsonUtility.ToJson(config, true);
#else
            var data = JsonUtility.ToJson(config, false);
#endif
            var file = GetConfigurationLocation();
            if (File.Exists(file) == false)
            {
                EnsureDirectories();
            }

            File.WriteAllText(file, data);
        }
コード例 #8
0
        private void EnsureConfiguration()
        {
            if (_config != null)
            {
                if (_platformsWithCustomData.Count == 0)
                {
                    foreach (SupportedPlatforms value in Enum.GetValues(typeof(SupportedPlatforms)))
                    {
                        _platformsWithCustomData.Add(value, _config.GetPlatformDeepLinkingProtocols(value) != null || _config.GetPlatformDomainProtocols(value) != null);
                    }
                }
                return;
            }

            _config = ConfigurationStorage.Load();
            SetupVariables();
        }
コード例 #9
0
        public void OnPreprocessBuild(BuildTarget target, string path)
        {
            EditorHelpers.SetPluginName("UniversalDeepLinking");

            var processor = GetProcessor(target);

            if (processor == null)
            {
                return;
            }


            AppLinkingConfiguration configuration = Storage.ConfigurationStorage.Load();


            processor.OnPreprocessBuild(configuration, path);
        }
コード例 #10
0
        private void AddDeepLinks(XmlDocument manifest, AppLinkingConfiguration configurations)
        {
            var activityNode = SearchUnityActivity(manifest);

            var nodeDeepLink = SearchIntentsBrowsable(activityNode);


            foreach (var xmlNode in nodeDeepLink)
            {
                if (RemoveOldDeepLinks(xmlNode))
                {
                    activityNode.RemoveChild(xmlNode);
                }
            }

            AddConfiguration(manifest, activityNode, configurations.GetPlatformDomainProtocols(SupportedPlatforms.Android, true), true);
            AddConfiguration(manifest, activityNode, configurations.GetPlatformDeepLinkingProtocols(SupportedPlatforms.Android, true));
        }
コード例 #11
0
        public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
        {
            FireCompletionEventAfterCall = true;
            AppLinkingConfiguration configuration = Storage.ConfigurationStorage.Load();

            var processor = GetProcessor(target);

            if (processor == null)
            {
                return;
            }
            EditorHelpers.SetPluginName("UniversalDeepLinking");

            processor.PostBuildProcess(configuration, pathToBuiltProject);

            if (FireCompletionEventAfterCall)
            {
                TriggerOnPostBuildProcessCompleted();
            }
        }
コード例 #12
0
        private void AddDomainAssociation(string pathToBuiltProject, AppLinkingConfiguration configuration)
        {
            string entitlementFilePath = "";

            var mtarget = _target == BuildTarget.iOS ? SupportedPlatforms.iOS : SupportedPlatforms.tvOS;

            if (!configuration.GetPlatformDomainProtocols(mtarget, true).Select(d => d.Host).Any())
            {
                return;
            }

            var entitlementsFiles = new DirectoryInfo(pathToBuiltProject).GetFiles("*.entitlements", SearchOption.AllDirectories);

            if (entitlementsFiles.Length == 0)
            {
                entitlementFilePath = CreateEntitlementsFile(pathToBuiltProject);
            }
            else
            {
                //
                //  Try to find the default entitlements file if any
                //
                var file = entitlementsFiles.FirstOrDefault(d => d.Name.ToLower().Contains("unity"));

                if (file == null)
                {
                    file = entitlementsFiles.First();
                }


                if (entitlementsFiles.Length > 1)
                {
                    Debug.LogWarning("Attention, it seems that you have multiple entitlements file. Only one will be added the Project : " + file.Name);
                }

                entitlementFilePath = file.FullName;
            }


            ChangeEntitlementAssociatedDomains(entitlementFilePath, configuration);
        }
コード例 #13
0
        //private bool IsXcodeBuild(string path)
        //{
        //    return path.EndsWith(".xcodeproj");
        //}
        public void PostBuildProcess(AppLinkingConfiguration configuration, string pathToBuiltProject)
        {
            BuildProcessor.FireCompletionEventAfterCall = false;
            IsXcodeBuild = CheckIfIsXcodeBuild(pathToBuiltProject);
#if UDL_DEBUG
            Debug.Log("UDL: path is " + pathToBuiltProject + " OS " + SystemInfo.operatingSystem + " Is Mac " + IsBuiltOnMac() + " IsXcodeBuild: " + IsXcodeBuild);
#endif


            //
            //  Unity sometimes doesn't include the .app in the pathToBuiltProject
            //
            if (Directory.Exists(pathToBuiltProject) == false)
            {
                pathToBuiltProject += ".app";
            }


            AddDeepLinks(configuration, pathToBuiltProject);

            if (IsXcodeBuild)
            {
                ExtractFrameworkAndAddItToXcode(pathToBuiltProject);
            }

            else
            {
                CopyUniversalDeepLinkFramework(pathToBuiltProject);

                if (IsBuiltOnMac())
                {
                    InjectFrameworkInGameApp(pathToBuiltProject);
                }
                else
                {
                    AddScriptsToIncludeFramework(pathToBuiltProject);
                    BuildProcessor.TriggerOnPostBuildProcessCompleted();
                }
            }
        }
コード例 #14
0
        private static void AddDomainAssociationConfiguration(AppLinkingConfiguration configuration, XElement elem, XElement extensions)
        {
            /*
             * <uap3:Extension Category="windows.appUriHandler">
             * <uap3:AppUriHandler>
             * <uap3:Host Name="sudokuzenkai.imaginationoverflow.com" />
             * <uap3:Host Name="www.sudokuzenkai.imaginationoverflow.com" />
             * </uap3:AppUriHandler>
             * </uap3:Extension>
             *
             */
            var config = configuration.GetPlatformDomainProtocols(SupportedPlatforms.UWP, true);

            if (config.Count == 0)
            {
                return;
            }

            var uap3Prefix = elem.GetNamespaceOfPrefix(DomainAssociationNamespacePrefix);

            var extension = new XElement(uap3Prefix + "Extension", new XAttribute(CategoryAttr, UriProtocol));

            extensions.Add(extension);

            var uriHandler = new XElement(uap3Prefix + "AppUriHandler");

            extension.Add(uriHandler);

            foreach (var domain in config.Select(d => d.Host).Distinct())
            {
                /*
                 * <uap3:Host Name="sudokuzenkai.imaginationoverflow.com"
                 */

                var host = new XElement(uap3Prefix + "Host", new XAttribute("Name", domain));

                uriHandler.Add(host);
            }
        }
コード例 #15
0
        public void OnPreprocessBuild(AppLinkingConfiguration configurations, string path)
        {
            if (configurations.GetPlatformDeepLinkingProtocols(SupportedPlatforms.Android, true).Count == 0 &&
                configurations.GetPlatformDomainProtocols(SupportedPlatforms.Android, true).Count == 0)
            {
                return;
            }

            string androidPluginsPath = Path.Combine(Application.dataPath, "Plugins/Android");
            string adjustManifestPath = Path.Combine(Application.dataPath, EditorHelpers.PluginPath + "/libs/Android/UniversalDeepLinkManifest.xml");

            adjustManifestPath = adjustManifestPath.Replace("Assets/", "");

            string appManifestPath = Path.Combine(Application.dataPath, "Plugins/Android/AndroidManifest.xml");

            if (!File.Exists(appManifestPath))
            {
                if (!Directory.Exists(androidPluginsPath))
                {
                    Directory.CreateDirectory(androidPluginsPath);
                }

                File.Copy(adjustManifestPath, appManifestPath);
            }


            XmlDocument manifestFile = new XmlDocument();

            manifestFile.Load(appManifestPath);

            AddDeepLinks(manifestFile, configurations);

            manifestFile.Save(appManifestPath);

            CleanManifestFile(appManifestPath);
        }
コード例 #16
0
    public override void OnInspectorGUI()
    {
        QuartersInit quartersInit = (QuartersInit)target;

        EditorGUILayout.LabelField($"Quarters Unity SDK - Version {QuartersInit.SDK_VERSION}");
        if (GUILayout.Button("Open App Dashboard"))
        {
            Application.OpenURL(quartersInit.DASHBOARD_URL);
        }
        if (GUILayout.Button("My Apps"))
        {
            Application.OpenURL(quartersInit.POQ_APPS_URL);
        }


        EditorGUILayout.Space();
        base.DrawDefaultInspector();

        if (GUILayout.Button("Save"))
        {
            AppLinkingConfiguration config = new AppLinkingConfiguration();

            config.DisplayName          = "Quarters SDK";
            config.DeepLinkingProtocols = new List <LinkInformation>();

            LinkInformation linkInformation = new LinkInformation();
            linkInformation.Scheme = "https";
            linkInformation.Host   = $"{quartersInit.APP_UNIQUE_IDENTIFIER}.games.poq.gg";


            config.DeepLinkingProtocols.Add(linkInformation);

            ConfigurationStorage.Save(config);
            Debug.Log("Saved Quarters SDK Config");
        }
    }
コード例 #17
0
        private void AddDeepLinks(AppLinkingConfiguration configuration, string pathToBuiltProject)
        {
            var plistDocumentPath = pathToBuiltProject + PListName;

            var plistDocument = new PlistDocument();

            plistDocument.ReadFromString(File.ReadAllText(plistDocumentPath));

            var rootElement = plistDocument.root;

            var bundleIdentifier = Application.identifier;

            var urlSchemeArrayElement = rootElement["CFBundleURLTypes"] as PlistElementArray;


            var configuredDeepLinks = new string[0];

            if (urlSchemeArrayElement == null)
            {
                urlSchemeArrayElement = rootElement.CreateArray("CFBundleURLTypes");
            }
            else
            {
                try
                {
                    configuredDeepLinks = urlSchemeArrayElement.values
                                          .Select(v => v.AsDict())
                                          .Where(d => d.values.ContainsKey("CFBundleURLSchemes"))
                                          .Select(d =>
                    {
                        PlistElement elem;
                        d.values.TryGetValue("CFBundleURLSchemes", out elem);
                        return(elem != null ? elem.AsString() : string.Empty);
                    }).ToArray();
                }
                catch (Exception e)
                {
                }
            }


            var mtarget = _target == BuildTarget.iOS ? SupportedPlatforms.iOS : SupportedPlatforms.tvOS;

            foreach (var configurationDeepLinkingProtocol in configuration.GetPlatformDeepLinkingProtocols(mtarget, true))
            {
                if (configuredDeepLinks.Contains(configurationDeepLinkingProtocol.Scheme))
                {
                    continue;
                }

                var urlTypeDic = urlSchemeArrayElement.AddDict();

                urlTypeDic.SetString("CFBundleURLName", bundleIdentifier);

                urlTypeDic.SetString("CFBundleTypeRole", "Viewer");

                var link = configurationDeepLinkingProtocol.Scheme;

                urlTypeDic.CreateArray("CFBundleURLSchemes").AddString(link);
            }

            File.WriteAllText(plistDocumentPath, plistDocument.WriteToString());
        }
コード例 #18
0
 public void PostBuildProcess(AppLinkingConfiguration configuration, string pathToBuiltProject)
 {
     UpdateApp(pathToBuiltProject);
     UpdateManifest(configuration, pathToBuiltProject);
 }