update: 完善 IOS ATT 打点和流程
							parent
							
								
									d26cc45962
								
							
						
					
					
						commit
						a009a220e4
					
				|  | @ -29,11 +29,20 @@ namespace Guru | ||||||
|         /// 使用自定义的Consent, 获取用户授权后, 调用此方法 |         /// 使用自定义的Consent, 获取用户授权后, 调用此方法 | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         /// <param name="userAllow"></param> |         /// <param name="userAllow"></param> | ||||||
|         public static void StartAdsWithCustomConsent(bool userAllow = true) |         /// <param name="guideType">Consent 引导的类型, 如果使用了 MAX 的 consent 请填写 max </param> | ||||||
|  |         public static void StartAdsWithCustomConsent(bool userAllow = true, string guideType = "custom") | ||||||
|         { |         { | ||||||
|  | #if UNITY_IOS | ||||||
|  |             _attType = guideType; | ||||||
|  |             InitAttStatus(); | ||||||
|  | #endif | ||||||
|             if (userAllow) |             if (userAllow) | ||||||
|             { |             { | ||||||
|  | #if UNITY_IOS | ||||||
|  |                 CheckAttStatus(); | ||||||
|  | #else | ||||||
|                 StartAdService(); |                 StartAdService(); | ||||||
|  | #endif | ||||||
|             } |             } | ||||||
|             else |             else | ||||||
|             { |             { | ||||||
|  | @ -56,6 +65,9 @@ namespace Guru | ||||||
| 
 | 
 | ||||||
|         private void OnConsentOver(int code) |         private void OnConsentOver(int code) | ||||||
|         { |         { | ||||||
|  | #if UNITY_IOS | ||||||
|  |             InitAttStatus(); | ||||||
|  | #endif | ||||||
|             Callbacks.ConsentFlow._onConsentResult?.Invoke(code); |             Callbacks.ConsentFlow._onConsentResult?.Invoke(code); | ||||||
|             switch(code) |             switch(code) | ||||||
|             { |             { | ||||||
|  | @ -63,27 +75,79 @@ namespace Guru | ||||||
|                 case GuruConsent.StatusCode.NOT_AVAILABLE: |                 case GuruConsent.StatusCode.NOT_AVAILABLE: | ||||||
|                     // 已获取授权, 或者地区不可用 |                     // 已获取授权, 或者地区不可用 | ||||||
| #if UNITY_IOS | #if UNITY_IOS | ||||||
|                     CheckATTStatus(); |                     CheckAttStatus(); | ||||||
| #else | #else | ||||||
|                     StartAdService(); |                     StartAdService(); | ||||||
| #endif | #endif | ||||||
|                     break; |                     break; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 |          | ||||||
|  |         #endregion | ||||||
|  |          | ||||||
|  |         #region IOS ATT 广告授权流程 | ||||||
|  |          | ||||||
| #if UNITY_IOS | #if UNITY_IOS | ||||||
|          /// <summary> |          | ||||||
|  |         private static string _initialAttStatus; | ||||||
|  |         private static String _attType = "admob"; | ||||||
|  |          | ||||||
|  |          | ||||||
|  |         /// <summary> | ||||||
|  |         /// 显示系统的 ATT 弹窗 | ||||||
|  |         /// </summary> | ||||||
|  |         public static void RequestAttDialog() | ||||||
|  |         { | ||||||
|  |             LogI($"RequestATTDialog"); | ||||||
|  |             ATTManager.RequestATTDailog(ReportAttStatus); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         /// <summary> | ||||||
|  |         /// 初始化 ATT 状态 | ||||||
|  |         /// </summary> | ||||||
|  |         public static void InitAttStatus() | ||||||
|  |         { | ||||||
|  |             _initialAttStatus = ATTManager.GetStatus(); | ||||||
|  |             SetUserProperty(Analytics.ParameterATTStatus, _initialAttStatus); // 上报一个初始的状态 | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         /// <summary> | ||||||
|         /// iOS 平台检查 ATT 状态 |         /// iOS 平台检查 ATT 状态 | ||||||
|         /// </summary> |         /// </summary> | ||||||
|         private void CheckATTStatus() |         private static void CheckAttStatus() => ATTManager.CheckStatus(ReportAttStatus); | ||||||
|  |           | ||||||
|  |         private static void ReportAttStatus(string status) | ||||||
|         { |         { | ||||||
|             AttManager.Instance.CheckATTStatus(OnATTStatus); |             LogI($"{Tag} --- Get Att status: {status}"); | ||||||
|         } |             SetUserProperty(Analytics.ParameterATTStatus, status); // 当前的状态 | ||||||
|  |             if (!string.IsNullOrEmpty(_initialAttStatus)  | ||||||
|  |                 && status !=  ATTManager.ATT_STATUS_NOT_DETERMINED | ||||||
|  |                 && _initialAttStatus != status) | ||||||
|  |             { | ||||||
|  |                 // 上报点位: | ||||||
|  |                 Analytics.AttResult(status, _attType); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  |             switch(status) | ||||||
|  |             { | ||||||
|  |                 case ATTManager.ATT_STATUS_NOT_DETERMINED: | ||||||
|  |                     // ATT 状态未知, 请求弹窗 | ||||||
|  |                     RequestAttDialog(); | ||||||
|  |                     break; | ||||||
|  |                 case ATTManager.ATT_STATUS_RESTRICTED: | ||||||
|  |                 case ATTManager.ATT_STATUS_DENIED: | ||||||
|  |                     // ATT 状态受限, 或者被拒绝, 不请求广告 | ||||||
|  |                     break; | ||||||
|  |                 case ATTManager.ATT_STATUS_AUTHORIZED: | ||||||
|  |                     // ATT 状态已授权, 请求广告 | ||||||
|  |                     StartAdService(); | ||||||
|  |                     break; | ||||||
|  |             } | ||||||
|  |         }  | ||||||
| #endif | #endif | ||||||
|          |          | ||||||
| 
 |         #endregion    | ||||||
|         #endregion |          | ||||||
| 
 |  | ||||||
|         #region Ad Services |         #region Ad Services | ||||||
| 
 | 
 | ||||||
|         private static bool _initAdsCompleted = false; |         private static bool _initAdsCompleted = false; | ||||||
|  |  | ||||||
|  | @ -143,7 +143,7 @@ namespace Guru | ||||||
|         private void OnFirebaseReady() |         private void OnFirebaseReady() | ||||||
|         { |         { | ||||||
|             IsInitialSuccess = true; |             IsInitialSuccess = true; | ||||||
|              |     | ||||||
|             if (!InitConfig.UseCustomConsent) |             if (!InitConfig.UseCustomConsent) | ||||||
|             { |             { | ||||||
|                 // LogI($"--- #3 Start Consent Flow ---"); |                 // LogI($"--- #3 Start Consent Flow ---"); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue