コード例 #1
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);
            }
        }
コード例 #2
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());
        }
コード例 #3
0
        private void DrawCustomPlatformLinkInformation()
        {
            GUILayout.Label("Platform Override Configurations", EditorStyles.boldLabel);
            foreach (SupportedPlatforms value in Enum.GetValues(typeof(SupportedPlatforms)))
            {
                _platformsWithCustomData[value] = EditorGUILayout.BeginToggleGroup(value.ToString(), _platformsWithCustomData[value]);

                if (_platformsWithCustomData[value])
                {
                    _config.ActivatePlatformOverride(value);
                    var deepLinking       = _config.GetPlatformDeepLinkingProtocols(value);
                    var domainAssociation = _config.GetPlatformDomainProtocols(value);
                    if (deepLinking == null)
                    {
                        deepLinking = _config.GetCustomDeepLinkingProtocols(value);
                    }

                    if (domainAssociation == null)
                    {
                        domainAssociation = _config.GetCustomDomainAssociation(value);
                    }


                    DrawLinkInformation(deepLinking, string.Format(DeepLinkLabelFormat, value.ToString()), value != SupportedPlatforms.Linux && value != SupportedPlatforms.Windows);
                    if ((value == SupportedPlatforms.Linux || value == SupportedPlatforms.Windows || value == SupportedPlatforms.OSX) == false)
                    {
                        DrawLinkInformation(domainAssociation, string.Format(DomainAssociationLabelFormat, value.ToString()));
                    }
                }
                else
                {
                    _config.DeactivatePlatformOverride(value);
                }
                EditorGUILayout.EndToggleGroup();
            }
        }
コード例 #4
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));
        }
コード例 #5
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);
        }
コード例 #6
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());
        }