From 18c7876f8f539203c1610ebad4de431787de0bb5 Mon Sep 17 00:00:00 2001 From: huyfei Date: Fri, 23 Feb 2024 14:32:15 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E9=A2=84=E5=85=88=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=B8=80=E4=B8=8B=20delay=20measurement=20=E7=9A=84=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PostBuildProcess/PostBuild.Android.DMA.cs | 21 +++++++++--- .../PostBuildProcess/PostBuild.iOS.DMA.cs | 33 ++++++++++--------- .../Runtime/Script/Consent/GoogleDMAHelper.cs | 1 + package.json | 2 +- 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/Runtime/GuruConsent/Editor/PostBuildProcess/PostBuild.Android.DMA.cs b/Runtime/GuruConsent/Editor/PostBuildProcess/PostBuild.Android.DMA.cs index 642173e..bda35e8 100644 --- a/Runtime/GuruConsent/Editor/PostBuildProcess/PostBuild.Android.DMA.cs +++ b/Runtime/GuruConsent/Editor/PostBuildProcess/PostBuild.Android.DMA.cs @@ -1,4 +1,3 @@ - #if UNITY_ANDROID namespace Guru.Editor @@ -32,6 +31,9 @@ namespace Guru.Editor * --------------------------------------------------------------------------------*/ + + public static bool DefaultValue = true; // default value + /// /// 修复 AndroidManifest.xml /// @@ -51,7 +53,7 @@ namespace Guru.Editor int[] flags = new int[] { 0, 0, 0, 0 }; - string defaultValue = "true"; // 日后可能会进行修改 + string defaultValue = DefaultValue.ToString().ToLower(); if (File.Exists(filePath)) { @@ -68,7 +70,7 @@ namespace Guru.Editor var list = app.SelectNodes("meta-data"); - // 刷新已有属性 + // ----- refresh exist values -------- foreach (XmlElement item in list) { for(int i = 0; i < dma_keys.Length; i++) @@ -81,17 +83,26 @@ namespace Guru.Editor } } - // 补全缺失属性 + // ------ Inject metadata ----------- for (int i = 0; i < flags.Length; i++) { if (flags[i] == 0) { var node = doc.CreateElement("meta-data"); - node.SetAttribute("name", namespace_uri,dma_keys[i]); + node.SetAttribute("name", namespace_uri, dma_keys[i]); node.SetAttribute("value", namespace_uri, defaultValue); app.AppendChild(node); } } + + // ------- Delay Measurement ------------ + if (GoogleDMAHelper.UsingDelayAppMeasurement) + { + var node = doc.CreateElement("meta-data"); + node.SetAttribute("name", namespace_uri, "com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT"); + node.SetAttribute("value", namespace_uri, "true"); + app.AppendChild(node); + } doc.Save(filePath); Debug.Log($"[Post] inject AndroidManifest.xml at {filePath} success."); diff --git a/Runtime/GuruConsent/Editor/PostBuildProcess/PostBuild.iOS.DMA.cs b/Runtime/GuruConsent/Editor/PostBuildProcess/PostBuild.iOS.DMA.cs index d0e100d..884364c 100644 --- a/Runtime/GuruConsent/Editor/PostBuildProcess/PostBuild.iOS.DMA.cs +++ b/Runtime/GuruConsent/Editor/PostBuildProcess/PostBuild.iOS.DMA.cs @@ -1,6 +1,5 @@ - - #if UNITY_IOS + namespace Guru.Editor { using UnityEditor; @@ -12,7 +11,7 @@ namespace Guru.Editor public class PostBuild_DMA { - public static bool DefaultValue = true; // 配置注入默认值 + public static bool DefaultValue = true; // default value [PostProcessBuild] public static void OnPostProcessBuild(BuildTarget target, string buildPath) @@ -20,7 +19,7 @@ namespace Guru.Editor if (target != BuildTarget.iOS) return; SetInfoPlist(buildPath); } - + /// /// inject default values /// @@ -38,24 +37,26 @@ namespace Guru.Editor plist.ReadFromFile(infoPlistPath); var root = plist.root; - root.SetBoolean("GADDelayAppMeasurementInit", true); + + //--------- Add Delay Measurement --------------- + if (GoogleDMAHelper.UsingDelayAppMeasurement) + { + root.SetBoolean("GADDelayAppMeasurementInit", true); + } + //--------- set all default values ---------- root.SetBoolean("GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_STORAGE", DefaultValue); root.SetBoolean("GOOGLE_ANALYTICS_DEFAULT_ALLOW_ANALYTICS_STORAGE", DefaultValue); root.SetBoolean("GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS", DefaultValue); root.SetBoolean("GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_USER_DATA", DefaultValue); - + plist.WriteToFile(infoPlistPath); - - Debug.Log($"[Post] consent has inject dma default values {DefaultValue} to {infoPlistPath} "); + + Debug.Log( + $"[Post] consent has inject dma default values {DefaultValue} to {infoPlistPath} "); } - - -#endif - - - - } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Runtime/GuruConsent/Runtime/Script/Consent/GoogleDMAHelper.cs b/Runtime/GuruConsent/Runtime/Script/Consent/GoogleDMAHelper.cs index c8aa45d..9ed2d97 100644 --- a/Runtime/GuruConsent/Runtime/Script/Consent/GoogleDMAHelper.cs +++ b/Runtime/GuruConsent/Runtime/Script/Consent/GoogleDMAHelper.cs @@ -14,6 +14,7 @@ namespace Guru /// public class GoogleDMAHelper { + public static readonly bool UsingDelayAppMeasurement = false; /// /// Set DMA status diff --git a/package.json b/package.json index 6e5d59b..6e6bdfd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.guru.unity.sdk.core", "displayName": "Guru SDK Core", - "version": "2.1.1", + "version": "2.2.0", "description": "Guru SDK core for Unity developers", "unity": "2021.3", "author":{