Compare commits
No commits in common. "c844ffcf2938860a18a282f33c4dfb6d01a668c9" and "c0c2c0b61e61dc1b26f2bbd1b671d2a764a8b8b4" have entirely different histories.
c844ffcf29
...
c0c2c0b61e
|
|
@ -55,10 +55,7 @@ namespace WZ
|
||||||
|
|
||||||
bannerAds.OnBannerAdLoadFailed += ((msg) =>
|
bannerAds.OnBannerAdLoadFailed += ((msg) =>
|
||||||
{
|
{
|
||||||
if (!_retryCounters.TryAdd(adUnitId, 0))
|
_retryCounters[adUnitId]++;
|
||||||
{
|
|
||||||
_retryCounters[adUnitId]++;
|
|
||||||
}
|
|
||||||
double retryDelay = Math.Pow(2, Math.Min(6, _retryCounters[adUnitId]));
|
double retryDelay = Math.Pow(2, Math.Min(6, _retryCounters[adUnitId]));
|
||||||
LoggerUtils.Debug($"[Admob] banner -[Load]: {adUnitId} failed, error message = {msg}");
|
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, double> _adRevenueCache = new Dictionary<string, double>();
|
||||||
private Dictionary<string, int> _retryCounters = new Dictionary<string, int>();
|
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)
|
public void InitializeAdUnits(List<string> adUnitIds)
|
||||||
{
|
{
|
||||||
|
|
@ -49,32 +49,17 @@ namespace WZ
|
||||||
{
|
{
|
||||||
_retryCounters[adUnitId]++;
|
_retryCounters[adUnitId]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
var adSource = "";
|
|
||||||
if (ad != null)
|
|
||||||
{
|
|
||||||
adSource = ad.GetResponseInfo().GetLoadedAdapterResponseInfo().AdSourceName;
|
|
||||||
}
|
|
||||||
|
|
||||||
var reason = "";
|
|
||||||
|
|
||||||
if (error != null)
|
|
||||||
{
|
|
||||||
reason = error.GetMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
AdsActionEvents.TrackAdFailToLoad(PlatformType.Admob,
|
AdsActionEvents.TrackAdFailToLoad(PlatformType.Admob,
|
||||||
adSource,
|
ad.GetResponseInfo().GetLoadedAdapterResponseInfo().AdSourceName,
|
||||||
adUnitId,
|
adUnitId,
|
||||||
AdsType.Native,
|
AdsType.Native,
|
||||||
Time.realtimeSinceStartup - _adStartLoadTimes[adUnitId], reason);
|
Time.realtimeSinceStartup - _adStartLoadTimes[adUnitId],error.GetMessage());
|
||||||
|
|
||||||
var retryDelay = Math.Pow(2, Math.Min(6, _retryCounters[adUnitId]));
|
var retryDelay = Math.Pow(2, Math.Min(6, _retryCounters[adUnitId]));
|
||||||
TimerUtils.Instance.DelayExecute((float)retryDelay, () => { LoadAd(adUnitId); });
|
TimerUtils.Instance.DelayExecute((float)retryDelay, () => { LoadAd(adUnitId); });
|
||||||
LoggerUtils.Debug("[Admob] Native ad failed to load an ad with error : " + error + " \n retryDelay :" + retryDelay);
|
LoggerUtils.Debug("[Admob] Native ad failed to load an ad with error : " + error + " \n retryDelay :" + retryDelay);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AdsActionEvents.TrackAdLoaded(PlatformType.Admob,
|
AdsActionEvents.TrackAdLoaded(PlatformType.Admob,
|
||||||
ad.GetResponseInfo().GetLoadedAdapterResponseInfo().AdSourceName,
|
ad.GetResponseInfo().GetLoadedAdapterResponseInfo().AdSourceName,
|
||||||
adUnitId,
|
adUnitId,
|
||||||
|
|
@ -112,16 +97,14 @@ namespace WZ
|
||||||
|
|
||||||
ad.OnAdFullScreenContentOpened += () => { LoggerUtils.Debug("[Admob] Native ad full screen content opened."); };
|
ad.OnAdFullScreenContentOpened += () => { LoggerUtils.Debug("[Admob] Native ad full screen content opened."); };
|
||||||
|
|
||||||
ad.OnAdFullScreenContentClosed += () =>
|
ad.OnAdFullScreenContentClosed += () => {
|
||||||
{
|
|
||||||
AdsActionEvents.TrackAdClicked(PlatformType.Admob,
|
AdsActionEvents.TrackAdClicked(PlatformType.Admob,
|
||||||
ad.GetResponseInfo().GetLoadedAdapterResponseInfo().AdSourceName,
|
ad.GetResponseInfo().GetLoadedAdapterResponseInfo().AdSourceName,
|
||||||
adUnitId,
|
adUnitId,
|
||||||
AdsType.Native,
|
AdsType.Native,
|
||||||
"",
|
"",
|
||||||
AdmobUtils.GetNativeEcpm(ad));
|
AdmobUtils.GetNativeEcpm(ad));
|
||||||
LoggerUtils.Debug("[Admob] Native ad full screen content closed.");
|
LoggerUtils.Debug("[Admob] Native ad full screen content closed."); };
|
||||||
};
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,10 +153,9 @@ namespace WZ
|
||||||
|
|
||||||
|
|
||||||
private float GetLoadedTime(string adUnitId)
|
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)
|
public bool IsAdAvailable(string adUnitId)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue