/// <summary>
        /// plistの更新をする
        /// </summary>
        /// <param name="buildPath"></param>
        /// <param name="settings"></param>
        private static void UpdatePlist(string buildPath, GoogleSettings settings)
        {
    #if UNITY_IOS
            PlistDocument plist    = new PlistDocument();
            string        filePath = Path.Combine(buildPath, "Info.plist");
            plist.ReadFromFile(filePath);

            PlistElement bundleUrlTypes = null;
            if (!plist.root.values.TryGetValue("CFBundleURLTypes", out bundleUrlTypes))
            {
                bundleUrlTypes = plist.root.CreateArray("CFBundleURLTypes");
            }

            // set url scheme
            PlistElementDict urlSchemeDict = bundleUrlTypes.AsArray().AddDict();
            urlSchemeDict.SetString("CFBundleTypeRole", "Editor");
            urlSchemeDict.CreateArray("CFBundleURLSchemes").AddString(settings.IOS.URLScheme);

            // set bundle id
            PlistElementDict bundleIdDict = bundleUrlTypes.AsArray().AddDict();
            bundleIdDict.SetString("CFBundleTypeRole", "Editor");
#if UNITY_5_6_OR_NEWER
            bundleIdDict.CreateArray("CFBundleURLSchemes").AddString(Application.identifier);
#else
            bundleIdDict.CreateArray("CFBundleURLSchemes").AddString(Application.bundleIdentifier);
#endif
            plist.WriteToFile(filePath);
#endif
        }
Example #2
0
    private static void DoAddSKAdNetworkItemsToInfo(string projectPath)
    {
        string infoPlistPath = Path.Combine(projectPath, "Info.plist");

        PlistDocument plistDoc = new PlistDocument();

        plistDoc.ReadFromFile(infoPlistPath);
        if (plistDoc.root != null)
        {
            PlistElementDict rootDict = plistDoc.root;

            PlistElement elementSKAdNetworkItems = rootDict["SKAdNetworkItems"];

            if (null == elementSKAdNetworkItems)
            {
                rootDict["SKAdNetworkItems"] = new PlistElementArray();

                elementSKAdNetworkItems = rootDict["SKAdNetworkItems"];
            }
            else
            {
                PlistElementArray arrayAdNetworkItems = elementSKAdNetworkItems.AsArray();
                int count = arrayAdNetworkItems.values.Count;
                arrayAdNetworkItems.values.RemoveRange(0, count);
            }

            PlistElementArray arrayItems = elementSKAdNetworkItems.AsArray();

            PlistElementArray addAdNetworks = DoGetAdNetworks();

            for (int i = 0; i < addAdNetworks.values.Count; i++)
            {
                PlistElementDict item = addAdNetworks.values[i] as PlistElementDict;
                arrayItems.values.Add(item);
            }

            plistDoc.WriteToFile(infoPlistPath);
        }
        else
        {
            Debug.LogError("Error: Can't open " + infoPlistPath);
        }
    }
Example #3
0
        static PlistElementArray GetOrCreateArray(PlistElementDict dict, string key)
        {
            PlistElement array = dict[key];

            if (array != null)
            {
                return(array.AsArray());
            }
            else
            {
                return(dict.CreateArray(key));
            }
        }
Example #4
0
    private static PlistElementArray DoGetAdNetworks()
    {
        string adNetworksPlistPath = Path.Combine(DoGetProjectFolder(), "Assets/10.Tools/AppTrackingTransparency/Editor/SKAdNetworkItems.plist");

        PlistDocument plistDoc = new PlistDocument();

        plistDoc.ReadFromFile(adNetworksPlistPath);

        PlistElement elementSKAdNetworkItems = plistDoc.root["SKAdNetworkItems"];

        if (null == elementSKAdNetworkItems)
        {
            plistDoc.root["SKAdNetworkItems"] = new PlistElementArray();

            elementSKAdNetworkItems = plistDoc.root["SKAdNetworkItems"];
        }

        PlistElementArray arrayItems = elementSKAdNetworkItems.AsArray();

        return(arrayItems);
    }
Example #5
0
    public static void AddDataToPlist(BuildTarget buildTarget, string pathToBuiltProject)
    {
        if (buildTarget == BuildTarget.iOS)
        {
                        #if UNITY_IOS
            //Build Data From Google Services File
            PlistDocument googlePlist = new PlistDocument();
            googlePlist.ReadFromString(File.ReadAllText(pathToBuiltProject + "/" + googleInfoPlistFilePath));
            string fireAppID = googlePlist.root ["REVERSED_CLIENT_ID"].AsString();

            // Get plist
            string        plistPath = pathToBuiltProject + "/Info.plist";
            PlistDocument plist     = new PlistDocument();
            plist.ReadFromString(File.ReadAllText(plistPath));

            // Get root
            PlistElementDict rootDict = plist.root;


            //1. Build Data
            PlistElementArray bundleUrlSchemaArr1 = new PlistElementArray();
            bundleUrlSchemaArr1.AddString(fireAppID);

            PlistElementArray bundleUrlSchemaArr2 = new PlistElementArray();
            bundleUrlSchemaArr2.AddString(Application.identifier);

            var               bundleUrlRootKey = "CFBundleURLTypes";
            PlistElement      bundleUrlData    = rootDict [bundleUrlRootKey];
            PlistElementArray bundleUrlAsArray = null;
            if (bundleUrlData == null)
            {
                bundleUrlAsArray = new PlistElementArray();
            }
            else
            {
                bundleUrlAsArray = bundleUrlData.AsArray();
            }

            //2..
            PlistElementDict bundleUrlItem1 = new PlistElementDict();
            bundleUrlItem1 ["CFBundleTypeRole"]   = new PlistElementString("Editor");
            bundleUrlItem1 ["CFBundleURLName"]    = new PlistElementString("google");
            bundleUrlItem1 ["CFBundleURLSchemes"] = bundleUrlSchemaArr1;

            bundleUrlAsArray.values.Add(bundleUrlItem1);

            //3.. (A hack for login crash issue)
            PlistElementDict bundleUrlItem2 = new PlistElementDict();
            bundleUrlItem2 ["CFBundleTypeRole"]   = new PlistElementString("Editor");
            bundleUrlItem2 ["CFBundleURLName"]    = new PlistElementString("lcgoogle");
            bundleUrlItem2 ["CFBundleURLSchemes"] = bundleUrlSchemaArr2;

            bundleUrlAsArray.values.Add(bundleUrlItem2);

            //3..
            rootDict [bundleUrlRootKey] = bundleUrlAsArray;

            // // ~~ Add GoogleSignIn Data // //


            // Write to file
            File.WriteAllText(plistPath, plist.WriteToString());

            Debug.Log("LCGoogleSignIn: iOS: AddDataToPlist for callbacks: Success");
                        #endif
        }
    }