private void SaveData() { _config.DisplayName = _displayName; _config.SteamId = _steamId; ConfigurationStorage.Save(_config); _config = null; }
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); }
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); } }
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()); }
public void PostBuildProcess(AppLinkingConfiguration configuration, string pathToBuiltProject) { ChangeIOSFlagsAndFrameworks(pathToBuiltProject); AddDeepLinks(configuration, pathToBuiltProject); AddDomainAssociation(pathToBuiltProject, configuration); }
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()); }
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); }
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(); }
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); }
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)); }
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(); } }
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); }
//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(); } } }
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); } }
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); }
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"); } }
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()); }
public void PostBuildProcess(AppLinkingConfiguration configuration, string pathToBuiltProject) { UpdateApp(pathToBuiltProject); UpdateManifest(configuration, pathToBuiltProject); }