update: 预先设置一下 delay measurement 的逻辑

deeplink
胡宇飞 2024-02-23 14:32:15 +08:00
parent 1bfbce04f1
commit 18c7876f8f
4 changed files with 35 additions and 22 deletions

View File

@ -1,4 +1,3 @@
#if UNITY_ANDROID
namespace Guru.Editor
@ -32,6 +31,9 @@ namespace Guru.Editor
*
--------------------------------------------------------------------------------*/
public static bool DefaultValue = true; // default value
/// <summary>
/// 修复 AndroidManifest.xml
/// </summary>
@ -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($"<color=#88ff00>[Post] inject AndroidManifest.xml at {filePath} success.</color>");

View File

@ -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);
}
/// <summary>
/// inject default values
/// </summary>
@ -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($"<color=#88ff00>[Post] consent has inject dma default values {DefaultValue} to {infoPlistPath} </color>");
Debug.Log(
$"<color=#88ff00>[Post] consent has inject dma default values {DefaultValue} to {infoPlistPath} </color>");
}
#endif
}
}
}
#endif

View File

@ -14,6 +14,7 @@ namespace Guru
/// </summary>
public class GoogleDMAHelper
{
public static readonly bool UsingDelayAppMeasurement = false;
/// <summary>
/// Set DMA status

View File

@ -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":{