Exemplo n.º 1
0
        public static void PostprocessBuild(BuildTarget buildTarget, string buildPath)
        {
            if (IdfaAuthorizationUtils.IsAttEnabled())
            {
                if (buildTarget != BuildTarget.iOS)
                {
                    return;
                }


                var plistPath = Path.Combine(buildPath, "Info.plist");
                var plist     = new PlistDocument();
                plist.ReadFromFile(plistPath);
                PlistElement element = plist.root[UserTrackingUsageDescriptionKey];


                PlistElementArray skAdNetworks = plist.root.CreateArray("SKAdNetworkItems");

                PlistElementDict fbSkanId = skAdNetworks.AddDict();
                fbSkanId.SetString("SKAdNetworkIdentifier", "v9wttpbfk9.skadnetwork");
                PlistElementDict fbSkanSecondaryId = skAdNetworks.AddDict();
                fbSkanSecondaryId.SetString("SKAdNetworkIdentifier", "n38lu8286q.skadnetwork");
                PlistElementDict snapSkanId = skAdNetworks.AddDict();
                snapSkanId.SetString("SKAdNetworkIdentifier", "424m5254lk.skadnetwork");


                plist.root.SetString(UserTrackingUsageDescriptionKey, IdfaAuthorizationConstants.UserTrackingUsageDescription);
                plist.WriteToFile(plistPath);
            }
        }
Exemplo n.º 2
0
        private void UpdateAppTrackingTransparencySymbol()
        {
            BuildTargetGroup group   = EditorUserBuildSettings.selectedBuildTargetGroup;
            string           symbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(group);

            bool isAttEnabled       = IdfaAuthorizationUtils.IsAttEnabled();
            bool isAttSymbolPresent = symbols.Contains(IdfaAuthorizationConstants.AppTrackingTransparencySymbol);

            if (isAttEnabled && !isAttSymbolPresent)
            {
                symbols = IdfaAuthorizationConstants.AppTrackingTransparencySymbol + ";" + symbols;
            }
            else if (!isAttEnabled && isAttSymbolPresent)
            {
                symbols = Regex.Replace(symbols, IdfaAuthorizationConstants.AppTrackingTransparencySymbol, "");
                symbols = Regex.Replace(symbols, ";;", ";");
            }

            PlayerSettings.SetScriptingDefineSymbolsForGroup(group, symbols);
        }