Compare commits
2 Commits
c0c2c0b61e
...
c844ffcf29
Author | SHA1 | Date |
---|---|---|
|
c844ffcf29 | |
|
d6bafaca55 |
|
@ -55,7 +55,10 @@ namespace WZ
|
|||
|
||||
bannerAds.OnBannerAdLoadFailed += ((msg) =>
|
||||
{
|
||||
_retryCounters[adUnitId]++;
|
||||
if (!_retryCounters.TryAdd(adUnitId, 0))
|
||||
{
|
||||
_retryCounters[adUnitId]++;
|
||||
}
|
||||
double retryDelay = Math.Pow(2, Math.Min(6, _retryCounters[adUnitId]));
|
||||
LoggerUtils.Debug($"[Admob] banner -[Load]: {adUnitId} failed, error message = {msg}");
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace WZ
|
|||
private Dictionary<string, double> _adRevenueCache = new Dictionary<string, double>();
|
||||
private Dictionary<string, int> _retryCounters = new Dictionary<string, int>();
|
||||
|
||||
private Dictionary<string,float> _adStartLoadTimes = new Dictionary<string, float>();
|
||||
private Dictionary<string, float> _adStartLoadTimes = new Dictionary<string, float>();
|
||||
|
||||
public void InitializeAdUnits(List<string> adUnitIds)
|
||||
{
|
||||
|
@ -49,17 +49,32 @@ namespace WZ
|
|||
{
|
||||
_retryCounters[adUnitId]++;
|
||||
}
|
||||
|
||||
var adSource = "";
|
||||
if (ad != null)
|
||||
{
|
||||
adSource = ad.GetResponseInfo().GetLoadedAdapterResponseInfo().AdSourceName;
|
||||
}
|
||||
|
||||
var reason = "";
|
||||
|
||||
if (error != null)
|
||||
{
|
||||
reason = error.GetMessage();
|
||||
}
|
||||
|
||||
AdsActionEvents.TrackAdFailToLoad(PlatformType.Admob,
|
||||
ad.GetResponseInfo().GetLoadedAdapterResponseInfo().AdSourceName,
|
||||
adSource,
|
||||
adUnitId,
|
||||
AdsType.Native,
|
||||
Time.realtimeSinceStartup - _adStartLoadTimes[adUnitId],error.GetMessage());
|
||||
|
||||
Time.realtimeSinceStartup - _adStartLoadTimes[adUnitId], reason);
|
||||
|
||||
var retryDelay = Math.Pow(2, Math.Min(6, _retryCounters[adUnitId]));
|
||||
TimerUtils.Instance.DelayExecute((float)retryDelay, () => { LoadAd(adUnitId); });
|
||||
LoggerUtils.Debug("[Admob] Native ad failed to load an ad with error : " + error + " \n retryDelay :" + retryDelay);
|
||||
return;
|
||||
}
|
||||
|
||||
AdsActionEvents.TrackAdLoaded(PlatformType.Admob,
|
||||
ad.GetResponseInfo().GetLoadedAdapterResponseInfo().AdSourceName,
|
||||
adUnitId,
|
||||
|
@ -97,14 +112,16 @@ namespace WZ
|
|||
|
||||
ad.OnAdFullScreenContentOpened += () => { LoggerUtils.Debug("[Admob] Native ad full screen content opened."); };
|
||||
|
||||
ad.OnAdFullScreenContentClosed += () => {
|
||||
ad.OnAdFullScreenContentClosed += () =>
|
||||
{
|
||||
AdsActionEvents.TrackAdClicked(PlatformType.Admob,
|
||||
ad.GetResponseInfo().GetLoadedAdapterResponseInfo().AdSourceName,
|
||||
adUnitId,
|
||||
AdsType.Native,
|
||||
"",
|
||||
AdmobUtils.GetNativeEcpm(ad));
|
||||
LoggerUtils.Debug("[Admob] Native ad full screen content closed."); };
|
||||
LoggerUtils.Debug("[Admob] Native ad full screen content closed.");
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -153,9 +170,10 @@ namespace WZ
|
|||
|
||||
|
||||
private float GetLoadedTime(string adUnitId)
|
||||
{
|
||||
return _adStartLoadTimes.TryGetValue(adUnitId, out var time)? time : 0;
|
||||
{
|
||||
return _adStartLoadTimes.TryGetValue(adUnitId, out var time) ? time : 0;
|
||||
}
|
||||
|
||||
// 检查特定广告位是否可用
|
||||
public bool IsAdAvailable(string adUnitId)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue