fix: 修复自打点和 Consent 的解析冲突问题
parent
d834446dc3
commit
282aaeadf4
|
|
@ -1,9 +1,11 @@
|
||||||
|
|
||||||
|
|
||||||
namespace Guru
|
namespace Guru
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -12,7 +14,7 @@ namespace Guru
|
||||||
public class GuruConsent
|
public class GuruConsent
|
||||||
{
|
{
|
||||||
// Guru Consent Version
|
// Guru Consent Version
|
||||||
public static string Version = "1.0.7";
|
public static string Version = "1.0.8";
|
||||||
public static string Tag = "[GuruConsent]";
|
public static string Tag = "[GuruConsent]";
|
||||||
|
|
||||||
#region 公用接口
|
#region 公用接口
|
||||||
|
|
@ -80,18 +82,40 @@ namespace Guru
|
||||||
|
|
||||||
//------- message send to unity ----------
|
//------- message send to unity ----------
|
||||||
Debug.Log($"{Tag} get callback msg:\n{msg}");
|
Debug.Log($"{Tag} get callback msg:\n{msg}");
|
||||||
|
try
|
||||||
var result = JsonConvert.DeserializeObject<ConsentResult>(msg);
|
|
||||||
|
|
||||||
if (result != null && result.action == "gdpr")
|
|
||||||
{
|
{
|
||||||
if (result.data != null)
|
var data = JsonConvert.DeserializeObject<JObject>(msg);
|
||||||
|
if (data != null && data.TryGetValue("action", out var jAtc))
|
||||||
{
|
{
|
||||||
Debug.Log($"{Tag} --- status: {result.data.status} msg: {result.data.msg}");
|
if (jAtc.ToString() == "gdpr")
|
||||||
onCompleteHandler?.Invoke(result.data.status);
|
{
|
||||||
return;
|
if(data.TryGetValue("data", out var jData))
|
||||||
|
{
|
||||||
|
if (jData is JObject jObj)
|
||||||
|
{
|
||||||
|
int status = StatusCode.UNKNOWN;
|
||||||
|
string message = "";
|
||||||
|
if (jObj.TryGetValue("status", out var jStatus))
|
||||||
|
{
|
||||||
|
int.TryParse(jStatus.ToString(), out status);
|
||||||
|
}
|
||||||
|
if (jObj.TryGetValue("msg", out var jMsg))
|
||||||
|
{
|
||||||
|
message = jMsg.ToString();
|
||||||
|
}
|
||||||
|
Debug.Log($"{Tag} --- status: {status} msg: {message}");
|
||||||
|
onCompleteHandler?.Invoke(status);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Analytics.LogCrashlytics(ex);
|
||||||
|
}
|
||||||
|
|
||||||
Debug.LogError($"{Tag} Parse callback Error");
|
Debug.LogError($"{Tag} Parse callback Error");
|
||||||
onCompleteHandler?.Invoke(StatusCode.UNKNOWN);
|
onCompleteHandler?.Invoke(StatusCode.UNKNOWN);
|
||||||
|
|
@ -110,26 +134,6 @@ namespace Guru
|
||||||
|
|
||||||
#region 常量定义
|
#region 常量定义
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// GDPR 状态对象
|
|
||||||
/// </summary>
|
|
||||||
[Serializable]
|
|
||||||
internal class ConsentResult
|
|
||||||
{
|
|
||||||
public string action = "";
|
|
||||||
public ConsentStatus data = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// GDPR 状态对象
|
|
||||||
/// </summary>
|
|
||||||
[Serializable]
|
|
||||||
internal class ConsentStatus
|
|
||||||
{
|
|
||||||
public int status;
|
|
||||||
public string msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Consent 状态
|
/// Consent 状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue