fix: 广告 SDK 优化广告重试时间 从最高间隔 8 秒 -> 64 秒, 减少无网时高频请求
--story=1020971 --user=yufei.hu 【中台】【ADS】优化 IV 和 RV 广告加载失败后的重试等待时间 https://www.tapd.cn/33527076/s/1157502 Signed-off-by: huyufei <yufei.hu@castbox.fm>main
							parent
							
								
									19a46fff1e
								
							
						
					
					
						commit
						72bf076537
					
				|  | @ -22,6 +22,8 @@ namespace Guru | |||
|         public bool IsInitialized => MaxSdk.IsInitialized() || _isServiceStarted; | ||||
|         protected bool IsNetworkEnabled => Application.internetReachability != NetworkReachability.NotReachable; | ||||
| 
 | ||||
|         private const int MAX_ADS_RELOAD_INTERVAL = 6; // 广告加载最高时间为 2 的 6 次方 = 64秒 | ||||
| 
 | ||||
|         private bool _isServiceStarted; | ||||
| 
 | ||||
|         protected Action _onSdkInitReady; | ||||
|  | @ -149,6 +151,13 @@ namespace Guru | |||
|             set => Model.BuyNoAds = value; | ||||
|         } | ||||
| 
 | ||||
|         private float GetRetryDelaySeconds(int retryCount) | ||||
|         { | ||||
|             // 最低 2^retryCount 秒 | ||||
|             // 最高 2^6 = 64 秒 | ||||
|             return (float)Math.Pow(2, Math.Min(MAX_ADS_RELOAD_INTERVAL, retryCount)); | ||||
|         } | ||||
| 
 | ||||
|         #region Lifecycele | ||||
|          | ||||
|         public void OnAppPaused(bool paused) | ||||
|  | @ -511,8 +520,8 @@ namespace Guru | |||
|             this.LogError( | ||||
|                 $"OnInterstitialFailedEvent AdLoadFailureInfo:{errorInfo.AdLoadFailureInfo}, Message: {errorInfo.Message}"); | ||||
|             _interstitialRetryAttempt++; | ||||
|             double retryDelay = Math.Pow(2, Math.Min(3, _interstitialRetryAttempt)); | ||||
|             DelayCall((float)retryDelay, RequestInterstitialAD); | ||||
|             float retryDelay = GetRetryDelaySeconds(_interstitialRetryAttempt); | ||||
|             DelayCall(retryDelay, RequestInterstitialAD); | ||||
|             // Analytics.ADIadsFailed(adUnitId, (int)errorInfo.Code, GetAdsLoadDuration(ref _iadsLoadStartTime), _iadsCategory); | ||||
|             Analytics.ADIadsFailed(AdParams.Build(adUnitId, | ||||
|                 duration: GetAdsLoadDuration(ref _iadsLoadStartTime), category: _iadsCategory, | ||||
|  | @ -669,8 +678,8 @@ namespace Guru | |||
|                 errorCode: (int)errorInfo.Code, | ||||
|                 waterfallName: errorInfo?.WaterfallInfo?.Name ?? "")); | ||||
|             _rewardRetryAttempt++; | ||||
|             double retryDelay = Math.Pow(2, Math.Min(3, _rewardRetryAttempt)); | ||||
|             DelayCall((float)retryDelay, RequestRewardedAD); | ||||
|             float retryDelay = GetRetryDelaySeconds(_rewardRetryAttempt); | ||||
|             DelayCall(retryDelay, RequestRewardedAD); | ||||
| 
 | ||||
|             OnRewardFailed?.Invoke(); | ||||
|         } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue