update: 更新AndroidID 和 IDFV 的属性上报
							parent
							
								
									495eaf4b49
								
							
						
					
					
						commit
						c71c468778
					
				|  | @ -126,6 +126,18 @@ namespace Guru | ||||||
|             Agent?.SetDeviceId(deviceId); |             Agent?.SetDeviceId(deviceId); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  |         public static void SetAndroidID(string androidId) | ||||||
|  |         { | ||||||
|  |             CacheUserProperty(Analytics.PropertyAndroidID, androidId); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         public static void SetIDFV(string idfv) | ||||||
|  |         { | ||||||
|  |             CacheUserProperty(Analytics.PropertyIDFV, idfv); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// 设置用户ID |         /// 设置用户ID | ||||||
|         /// </summary> |         /// </summary> | ||||||
|  |  | ||||||
|  | @ -104,6 +104,8 @@ namespace Guru | ||||||
| 		public static readonly string PropertyCoin = "coin"; //当前金币数 | 		public static readonly string PropertyCoin = "coin"; //当前金币数 | ||||||
| 		public static readonly string PropertyExp = "exp"; // 经验值 | 		public static readonly string PropertyExp = "exp"; // 经验值 | ||||||
| 		public static readonly string PropertyHp = "hp"; // 生命值/体力 | 		public static readonly string PropertyHp = "hp"; // 生命值/体力 | ||||||
|  | 		public static readonly string PropertyAndroidID = "android_id"; // Android 平台 AndroidID | ||||||
|  | 		public static readonly string PropertyIDFV = "idfv"; // iOS  平台 IDFV | ||||||
| 		public static readonly string PropertyPicture = "picture"; // 玩家在主线的mapid | 		public static readonly string PropertyPicture = "picture"; // 玩家在主线的mapid | ||||||
| 		public static readonly string PropertyNoAds = "no_ads"; // 玩家是否去广告 | 		public static readonly string PropertyNoAds = "no_ads"; // 玩家是否去广告 | ||||||
| 		public static readonly string PropertyATTStatus = "att_status";  // ATT 状态 | 		public static readonly string PropertyATTStatus = "att_status";  // ATT 状态 | ||||||
|  |  | ||||||
|  | @ -191,8 +191,24 @@ namespace Guru | ||||||
| 		    string status = ATTManager.GetStatus(); | 		    string status = ATTManager.GetStatus(); | ||||||
| 		    GuruAnalytics.SetUserProperty(ParameterATTStatus, status); | 		    GuruAnalytics.SetUserProperty(ParameterATTStatus, status); | ||||||
| 	    } | 	    } | ||||||
| #endif   |  | ||||||
| 
 | 
 | ||||||
|  | 	    private static void SetIDFV() | ||||||
|  | 	    { | ||||||
|  | 		    GuruAnalytics.SetAndroidID(DeviceIDHelper.IDFV); | ||||||
|  | 	    } | ||||||
|  | 	     | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | #if UNITY_ANDROID  | ||||||
|  | 		/// <summary> | ||||||
|  | 	    /// 更新 Android ID 的参数 | ||||||
|  | 	    /// </summary> | ||||||
|  | 	    private static void SetAndroidId() | ||||||
|  | 	    { | ||||||
|  | 		    GuruAnalytics.SetAndroidID(DeviceIDHelper.AndroidID); | ||||||
|  | 	    } | ||||||
|  | #endif	     | ||||||
|  | 	     | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
| 		/// 获取全部ID | 		/// 获取全部ID | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
|  | @ -203,8 +219,14 @@ namespace Guru | ||||||
| 			SetAdjustId(); | 			SetAdjustId(); | ||||||
| 			SetFirebaseId(); | 			SetFirebaseId(); | ||||||
| 			SetAdId(); | 			SetAdId(); | ||||||
|  | 			 | ||||||
|  | #if UNITY_ANDROID | ||||||
|  | 			SetAndroidId(); | ||||||
|  | #endif | ||||||
|  | 			 | ||||||
| #if UNITY_IOS | #if UNITY_IOS | ||||||
| 			SetATTStatus(); | 			SetATTStatus(); | ||||||
|  | 			SetIDFV(); | ||||||
| #endif   | #endif   | ||||||
| 			ReportEventSuccessRate(); | 			ReportEventSuccessRate(); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | @ -0,0 +1,50 @@ | ||||||
|  | 
 | ||||||
|  | namespace Guru | ||||||
|  | { | ||||||
|  |     public class DeviceIDHelper | ||||||
|  |     { | ||||||
|  |         /// <summary> | ||||||
|  |         /// UUID (V4)  | ||||||
|  |         /// </summary> | ||||||
|  |         /// <returns></returns> | ||||||
|  |         public static string UUID => System.Guid.NewGuid().ToString(); | ||||||
|  |          | ||||||
|  | 
 | ||||||
|  |         /// <summary> | ||||||
|  |         /// IOS 或者 IDFV | ||||||
|  |         /// 当获取到非法的值时, 用 UUID 代替 | ||||||
|  |         /// </summary> | ||||||
|  |         /// <returns></returns> | ||||||
|  |         public static string IDFV | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 var idfv = UnityEngine.SystemInfo.deviceUniqueIdentifier; | ||||||
|  |                 if (string.IsNullOrEmpty(idfv) || idfv.Contains("0000-0000-0000")) | ||||||
|  |                 { | ||||||
|  |                     idfv = UUID; | ||||||
|  |                 } | ||||||
|  |                 return idfv; | ||||||
|  |             } | ||||||
|  |              | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         /// <summary> | ||||||
|  |         /// Android ID | ||||||
|  |         /// 可通过Unity 本身的接口来获取 | ||||||
|  |         /// </summary> | ||||||
|  |         /// <returns></returns> | ||||||
|  |         public static string AndroidID | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 var aid = UnityEngine.SystemInfo.deviceUniqueIdentifier; | ||||||
|  |                 if (string.IsNullOrEmpty(aid)) aid = UUID; | ||||||
|  |                 return aid; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -1,46 +0,0 @@ | ||||||
| 
 |  | ||||||
| namespace Guru |  | ||||||
| { |  | ||||||
|     public class DeviceIDUtil |  | ||||||
|     { |  | ||||||
|         /// <summary> |  | ||||||
|         /// UUID (V4)  |  | ||||||
|         /// </summary> |  | ||||||
|         /// <returns></returns> |  | ||||||
|         public static string UUID => System.Guid.NewGuid().ToString(); |  | ||||||
|          |  | ||||||
| #if UNITY_IOS |  | ||||||
|         /// <summary> |  | ||||||
|         /// IOS 或者 IDFV |  | ||||||
|         /// 当获取到非法的值时, 用 UUID 代替 |  | ||||||
|         /// </summary> |  | ||||||
|         /// <returns></returns> |  | ||||||
|         public static string IDFV() |  | ||||||
|         { |  | ||||||
|             var idfv = UnityEngine.SystemInfo.deviceUniqueIdentifier; |  | ||||||
|             if (string.IsNullOrEmpty(idfv) || idfv.Contains("0000-0000-0000")) |  | ||||||
|             { |  | ||||||
|                 idfv = UUID; |  | ||||||
|             } |  | ||||||
|             return idfv; |  | ||||||
|         } |  | ||||||
|          |  | ||||||
| #endif |  | ||||||
|          |  | ||||||
| #if UNITY_ANDROID |  | ||||||
|         /// <summary> |  | ||||||
|         /// Android ID |  | ||||||
|         /// 可通过Unity 本身的接口来获取 |  | ||||||
|         /// </summary> |  | ||||||
|         /// <returns></returns> |  | ||||||
|         public static string AndroidID() |  | ||||||
|         { |  | ||||||
|             var aid = UnityEngine.SystemInfo.deviceUniqueIdentifier; |  | ||||||
|             if (string.IsNullOrEmpty(aid)) aid = UUID; |  | ||||||
|             return aid; |  | ||||||
|         } |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  | @ -76,18 +76,18 @@ namespace Guru | ||||||
| 			var did = SystemInfo.deviceUniqueIdentifier; | 			var did = SystemInfo.deviceUniqueIdentifier; | ||||||
| 			if (!IsValidDeviceId(did)) | 			if (!IsValidDeviceId(did)) | ||||||
| 			{ | 			{ | ||||||
| 				//空串, 或者IOS 生成了无效的 IDFV, 则使用 DeviceIDUtil 代替 | 				//空串, 或者IOS 生成了无效的 IDFV, 则使用 DeviceIDHelper 代替 | ||||||
| 				did = DeviceIDUtil.UUID; | 				did = DeviceIDHelper.UUID; | ||||||
| 			} | 			} | ||||||
| 			return did; | 			return did; | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
| 		/// 用生成设备ID (V2) | 		/// 用生成设备ID (V2) | ||||||
| 		/// 直接使用 DeviceIDUtil 作为设备的唯一标识 | 		/// 直接使用 DeviceIDHelper 作为设备的唯一标识 | ||||||
| 		/// </summary> | 		/// </summary> | ||||||
| 		/// <returns></returns> | 		/// <returns></returns> | ||||||
| 		private static string GenerateDeviceIdV2() => DeviceIDUtil.UUID; | 		private static string GenerateDeviceIdV2() => DeviceIDHelper.UUID; | ||||||
| 
 | 
 | ||||||
| 		 | 		 | ||||||
| 		/// <summary> | 		/// <summary> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue