/// <summary> /// URL Scheme が設定済みか判定する /// </summary> /// <returns><c>true</c>, if if URL scheme exists was checked, <c>false</c> otherwise.</returns> /// <param name="dictContainer">Dict container.</param> /// <param name="urlScheme">URL scheme.</param> private static bool CheckIfUrlSchemeExists(XmlNode dictContainer, string urlScheme) { foreach (XmlNode dict in dictContainer.ChildNodes) { if (dict.Name.ToLower().Equals("dict")) { PListItem bundleUrlSchemes = GetPlistItem(dict, "CFBundleURLSchemes"); if (bundleUrlSchemes != null) { if (bundleUrlSchemes.itemValueNode.Name.Equals("array")) { foreach (XmlNode str in bundleUrlSchemes.itemValueNode.ChildNodes) { if (str.Name.Equals("string")) { if (str.InnerText.Equals(urlScheme)) { return(true); } } else { Debug.Log("CFBundleURLSchemes array contains illegal elements."); } } } else { Debug.Log("CFBundleURLSchemes contains illegal elements."); } } } else { Debug.Log("CFBundleURLTypes contains illegal elements."); } } return(false); }
private static void ProcessInfoPList(string path, string clientId) { try { string file = System.IO.Path.Combine(path, "Info.plist"); if(!File.Exists(file)) { return; } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(file); XmlNode dict = xmlDocument.SelectSingleNode("plist/dict"); if(dict != null) { // Add Facebook application id if not defined PListItem facebookAppId = GetPlistItem(dict, "FacebookAppID"); if(facebookAppId == null) { XmlElement key = xmlDocument.CreateElement("key"); key.InnerText = "FacebookAppID"; XmlElement str = xmlDocument.CreateElement("string"); str.InnerText = FacebookAppId; dict.AppendChild(key); dict.AppendChild(str); } // Add url schemes PListItem bundleUrlTypes = GetPlistItem(dict, "CFBundleURLTypes"); if(bundleUrlTypes == null) { XmlElement key = xmlDocument.CreateElement("key"); key.InnerText = "CFBundleURLTypes"; XmlElement array = xmlDocument.CreateElement("array"); bundleUrlTypes = new PListItem(dict.AppendChild(key), dict.AppendChild(array)); } AddUrlScheme(xmlDocument, bundleUrlTypes.itemValueNode, UrlSchemePrefixFB + clientId); AddUrlScheme(xmlDocument, bundleUrlTypes.itemValueNode, UrlSchemePrefixEP + clientId); xmlDocument.Save(file); // Remove extra gargabe added by the XmlDocument save UpdateStringInFile(file, "dtd\"[]>", "dtd\">"); } else { Debug.Log("Info.plist is not valid"); } } catch(Exception e) { Debug.Log("Unable to update Info.plist: " + e); } }
private static void ProcessInfoPList(string path, string clientId) { try { string file = System.IO.Path.Combine(path, "Info.plist"); if (!File.Exists(file)) { return; } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(file); XmlNode dict = xmlDocument.SelectSingleNode("plist/dict"); if (dict != null) { // Add camera usage description for iOS 10 PListItem cameraUsageDescription = GetPlistItem(dict, "NSCameraUsageDescription"); if (cameraUsageDescription == null) { XmlElement key = xmlDocument.CreateElement("key"); key.InnerText = "NSCameraUsageDescription"; XmlElement str = xmlDocument.CreateElement("string"); str.InnerText = "Everyplay requires access to the camera"; dict.AppendChild(key); dict.AppendChild(str); } // Add microphone usage description for iOS 10 PListItem microphoneUsageDescription = GetPlistItem(dict, "NSMicrophoneUsageDescription"); if (microphoneUsageDescription == null) { XmlElement key = xmlDocument.CreateElement("key"); key.InnerText = "NSMicrophoneUsageDescription"; XmlElement str = xmlDocument.CreateElement("string"); str.InnerText = "Everyplay requires access to the microphone"; dict.AppendChild(key); dict.AppendChild(str); } // Add photo library usage description for iOS 10 PListItem photoLibraryUsageDescription = GetPlistItem(dict, "NSPhotoLibraryUsageDescription"); if (photoLibraryUsageDescription == null) { XmlElement key = xmlDocument.CreateElement("key"); key.InnerText = "NSPhotoLibraryUsageDescription"; XmlElement str = xmlDocument.CreateElement("string"); str.InnerText = "Everyplay requires access to the photo library"; dict.AppendChild(key); dict.AppendChild(str); } // Add Facebook application id if not defined PListItem facebookAppId = GetPlistItem(dict, "FacebookAppID"); if (facebookAppId == null) { XmlElement key = xmlDocument.CreateElement("key"); key.InnerText = "FacebookAppID"; XmlElement str = xmlDocument.CreateElement("string"); str.InnerText = FacebookAppId; dict.AppendChild(key); dict.AppendChild(str); } // Add url schemes PListItem bundleUrlTypes = GetPlistItem(dict, "CFBundleURLTypes"); if (bundleUrlTypes == null) { XmlElement key = xmlDocument.CreateElement("key"); key.InnerText = "CFBundleURLTypes"; XmlElement array = xmlDocument.CreateElement("array"); bundleUrlTypes = new PListItem(dict.AppendChild(key), dict.AppendChild(array)); } AddUrlScheme(xmlDocument, bundleUrlTypes.itemValueNode, UrlSchemePrefixFB + clientId); AddUrlScheme(xmlDocument, bundleUrlTypes.itemValueNode, UrlSchemePrefixEP + clientId); xmlDocument.Save(file); // Remove extra gargabe added by the XmlDocument save UpdateStringInFile(file, "dtd\"[]>", "dtd\">"); } else { Debug.Log("Info.plist is not valid"); } } catch (Exception e) { Debug.Log("Unable to update Info.plist: " + e); } }
// Info.plist を書き換える private static void ReWriteInfoPList (string path, string clientId) { try { string file = System.IO.Path.Combine (path, "Info.plist"); if (!File.Exists (file)) { return; } XmlDocument xmlDocument = new XmlDocument (); xmlDocument.Load (file); XmlNode dict = xmlDocument.SelectSingleNode ("plist/dict"); if (dict != null) { // Add url schemes PListItem bundleUrlTypes = GetPlistItem (dict, "CFBundleURLTypes"); if (bundleUrlTypes == null) { XmlElement key = xmlDocument.CreateElement ("key"); key.InnerText = "CFBundleURLTypes"; XmlElement array = xmlDocument.CreateElement ("array"); bundleUrlTypes = new PListItem (dict.AppendChild (key), dict.AppendChild (array)); } AddUrlScheme (xmlDocument, bundleUrlTypes.itemValueNode, URL_SCHEME_PREFIX_LOBI + clientId); // Add LSApplicationQueriesSchemes PListItem applicationQueriesSchemes = GetPlistItem (dict, "LSApplicationQueriesSchemes"); if (applicationQueriesSchemes == null) { XmlElement key = xmlDocument.CreateElement ("key"); key.InnerText = "LSApplicationQueriesSchemes"; XmlElement array = xmlDocument.CreateElement ("array"); applicationQueriesSchemes = new PListItem (dict.AppendChild (key), dict.AppendChild (array)); } string[] queriesSchemes = new string[]{ URL_SCHEME_PREFIX_LOBI + clientId, "nakamap-sso", "nakamap", "lobi", "line" }; AddApplicationQueriesSchemes (xmlDocument, applicationQueriesSchemes.itemValueNode, queriesSchemes); xmlDocument.Save (file); // Remove extra gargabe added by the XmlDocument save UpdateStringInFile (file, "dtd\"[]>", "dtd\">"); } else { Debug.Log ("Info.plist is not valid"); } } catch (Exception e) { Debug.Log ("Unable to update Info.plist: " + e); } }