fix: 修复自打点和 Consent 的解析冲突问题
							parent
							
								
									d834446dc3
								
							
						
					
					
						commit
						282aaeadf4
					
				|  | @ -1,9 +1,11 @@ | |||
| 
 | ||||
| 
 | ||||
| namespace Guru | ||||
| { | ||||
|     using System; | ||||
|     using System.Collections; | ||||
|     using Newtonsoft.Json; | ||||
|     using Newtonsoft.Json.Linq; | ||||
|     using UnityEngine; | ||||
|      | ||||
|     /// <summary> | ||||
|  | @ -12,7 +14,7 @@ namespace Guru | |||
|     public class GuruConsent | ||||
|     { | ||||
|         // Guru Consent Version | ||||
|         public static string Version = "1.0.7"; | ||||
|         public static string Version = "1.0.8"; | ||||
|         public static string Tag = "[GuruConsent]"; | ||||
| 
 | ||||
|         #region 公用接口 | ||||
|  | @ -80,19 +82,41 @@ namespace Guru | |||
|              | ||||
|             //------- message send to unity ---------- | ||||
|             Debug.Log($"{Tag} get callback msg:\n{msg}"); | ||||
| 
 | ||||
|             var result = JsonConvert.DeserializeObject<ConsentResult>(msg); | ||||
|              | ||||
|             if (result != null && result.action == "gdpr") | ||||
|             try | ||||
|             { | ||||
|                 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}"); | ||||
|                     onCompleteHandler?.Invoke(result.data.status); | ||||
|                     if (jAtc.ToString() == "gdpr") | ||||
|                     { | ||||
|                         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"); | ||||
|             onCompleteHandler?.Invoke(StatusCode.UNKNOWN); | ||||
|         } | ||||
|  | @ -110,26 +134,6 @@ namespace Guru | |||
|          | ||||
|         #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> | ||||
|         /// Consent 状态 | ||||
|         /// </summary> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue