Compare commits
2 Commits
017aa5de36
...
295b16d3cd
Author | SHA1 | Date |
---|---|---|
|
295b16d3cd | |
|
cc00dd82c2 |
|
@ -436,6 +436,40 @@ namespace WZ
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 判断当前广告id的配置是否包含这个id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="adsType"></param>
|
||||||
|
/// <param name="adUnitId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool FindAdsID(AdsType adsType, string adUnitId)
|
||||||
|
{
|
||||||
|
if (adsType == AdsType.Rewarded)
|
||||||
|
{
|
||||||
|
return _rewardedAdUnits.Contains(adUnitId);
|
||||||
|
}
|
||||||
|
else if (adsType == AdsType.Interstitial)
|
||||||
|
{
|
||||||
|
return _interstitialAdUnits.Contains(adUnitId);
|
||||||
|
}
|
||||||
|
else if (adsType == AdsType.Native)
|
||||||
|
{
|
||||||
|
return _nativeAdUnits.Contains(adUnitId);
|
||||||
|
}
|
||||||
|
else if (adsType == AdsType.Splash)
|
||||||
|
{
|
||||||
|
return _splashAdUnits.Contains(adUnitId);
|
||||||
|
}
|
||||||
|
else if (adsType == AdsType.Banner)
|
||||||
|
{
|
||||||
|
return _bannerAdUnits.Contains(adUnitId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,10 @@ namespace WZ
|
||||||
|
|
||||||
public void LoadAd(string adUnitId)
|
public void LoadAd(string adUnitId)
|
||||||
{
|
{
|
||||||
|
if (!AdmobAdsManager.Instance.FindAdsID(AdsType.Banner, adUnitId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (_bannerAds.TryGetValue(adUnitId, out var ad))
|
if (_bannerAds.TryGetValue(adUnitId, out var ad))
|
||||||
{
|
{
|
||||||
ad.LoadAd(new AdRequest());
|
ad.LoadAd(new AdRequest());
|
||||||
|
@ -122,6 +126,11 @@ namespace WZ
|
||||||
// 显示特定广告位的广告
|
// 显示特定广告位的广告
|
||||||
private void ShowAd(string adUnitId)
|
private void ShowAd(string adUnitId)
|
||||||
{
|
{
|
||||||
|
if (!AdmobAdsManager.Instance.FindAdsID(AdsType.Banner, adUnitId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (_bannerAds.TryGetValue(adUnitId, out var ad))
|
if (_bannerAds.TryGetValue(adUnitId, out var ad))
|
||||||
{
|
{
|
||||||
ad.Show();
|
ad.Show();
|
||||||
|
|
|
@ -49,6 +49,11 @@ namespace WZ
|
||||||
onAdLoadFailed?.Invoke(adUnitId, error.GetCode(), error.GetMessage());
|
onAdLoadFailed?.Invoke(adUnitId, error.GetCode(), error.GetMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!AdmobAdsManager.Instance.FindAdsID(AdsType.Interstitial, adUnitId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LoggerUtils.Debug("Admob Interstitial ad loaded with response : " + ad.GetResponseInfo().ToString());
|
LoggerUtils.Debug("Admob Interstitial ad loaded with response : " + ad.GetResponseInfo().ToString());
|
||||||
_interstitialAds[adUnitId] = ad;
|
_interstitialAds[adUnitId] = ad;
|
||||||
|
@ -128,6 +133,10 @@ namespace WZ
|
||||||
// 检查特定广告位是否可用
|
// 检查特定广告位是否可用
|
||||||
private bool IsAdAvailable(string adUnitId)
|
private bool IsAdAvailable(string adUnitId)
|
||||||
{
|
{
|
||||||
|
if (!AdmobAdsManager.Instance.FindAdsID(AdsType.Interstitial, adUnitId))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return _interstitialAds.TryGetValue(adUnitId, out var ad) && ad.CanShowAd();
|
return _interstitialAds.TryGetValue(adUnitId, out var ad) && ad.CanShowAd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,11 @@ namespace WZ
|
||||||
public void LoadAd(string adUnitId)
|
public void LoadAd(string adUnitId)
|
||||||
{
|
{
|
||||||
LoggerUtils.Debug($"[Admob] Native Ad unit {adUnitId} load start");
|
LoggerUtils.Debug($"[Admob] Native Ad unit {adUnitId} load start");
|
||||||
|
//判断在线参数是否包含这个id
|
||||||
|
if (!AdmobAdsManager.Instance.FindAdsID(AdsType.Native, adUnitId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
NativeOverlayAd.Load(adUnitId, new AdRequest(), new NativeAdOptions(), (NativeOverlayAd ad, LoadAdError error) =>
|
NativeOverlayAd.Load(adUnitId, new AdRequest(), new NativeAdOptions(), (NativeOverlayAd ad, LoadAdError error) =>
|
||||||
{
|
{
|
||||||
|
@ -76,6 +81,11 @@ namespace WZ
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!AdmobAdsManager.Instance.FindAdsID(AdsType.Native, adUnitId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
AdsActionEvents.TrackAdLoaded(PlatformType.Admob,
|
AdsActionEvents.TrackAdLoaded(PlatformType.Admob,
|
||||||
ad.GetResponseInfo().GetLoadedAdapterResponseInfo().AdSourceName,
|
ad.GetResponseInfo().GetLoadedAdapterResponseInfo().AdSourceName,
|
||||||
|
@ -143,6 +153,11 @@ namespace WZ
|
||||||
// 显示特定广告位的广告
|
// 显示特定广告位的广告
|
||||||
public void ShowAd(NativeAdPosition position, string adUnitId)
|
public void ShowAd(NativeAdPosition position, string adUnitId)
|
||||||
{
|
{
|
||||||
|
if (!AdmobAdsManager.Instance.FindAdsID(AdsType.Native, adUnitId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
LoggerUtils.Debug($"[Admob] Native ad ShowAd start {adUnitId} , {position}");
|
LoggerUtils.Debug($"[Admob] Native ad ShowAd start {adUnitId} , {position}");
|
||||||
|
|
||||||
if (_nativeAds.TryGetValue(adUnitId, out var ad))
|
if (_nativeAds.TryGetValue(adUnitId, out var ad))
|
||||||
|
@ -292,6 +307,7 @@ namespace WZ
|
||||||
_adStartLoadTimes.Remove(key);
|
_adStartLoadTimes.Remove(key);
|
||||||
_adRevenueCache.Remove(key);
|
_adRevenueCache.Remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -53,6 +53,11 @@ namespace WZ
|
||||||
|
|
||||||
LoggerUtils.Debug("[Admob] rewarded ad loaded with response : " + ad.GetResponseInfo().ToString()+"revenue:"+AdmobUtils.GetRewardedAdEcpm(ad));
|
LoggerUtils.Debug("[Admob] rewarded ad loaded with response : " + ad.GetResponseInfo().ToString()+"revenue:"+AdmobUtils.GetRewardedAdEcpm(ad));
|
||||||
LoggerUtils.Debug("[Admob] rewarded ad revenue : " +AdmobUtils.GetRewardedAdEcpm(ad));
|
LoggerUtils.Debug("[Admob] rewarded ad revenue : " +AdmobUtils.GetRewardedAdEcpm(ad));
|
||||||
|
|
||||||
|
if (!AdmobAdsManager.Instance.FindAdsID(AdsType.Rewarded, adUnitId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_rewardedAds[adUnitId] = ad;
|
_rewardedAds[adUnitId] = ad;
|
||||||
_adRevenueCache[adUnitId] = AdmobUtils.GetRewardedAdEcpm(ad);
|
_adRevenueCache[adUnitId] = AdmobUtils.GetRewardedAdEcpm(ad);
|
||||||
|
@ -128,6 +133,10 @@ namespace WZ
|
||||||
// 检查特定广告位是否可用
|
// 检查特定广告位是否可用
|
||||||
private bool IsAdAvailable(string adUnitId)
|
private bool IsAdAvailable(string adUnitId)
|
||||||
{
|
{
|
||||||
|
if (!AdmobAdsManager.Instance.FindAdsID(AdsType.Rewarded, adUnitId))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return _rewardedAds.TryGetValue(adUnitId, out var ad) && ad.CanShowAd();
|
return _rewardedAds.TryGetValue(adUnitId, out var ad) && ad.CanShowAd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue