添加接口
This commit is contained in:
parent
2a560acb56
commit
46c1cfb845
|
@ -53,7 +53,7 @@ namespace WZ
|
||||||
network.RefreshAdsData();
|
network.RefreshAdsData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#region 激励视频广告
|
||||||
public bool IsRewardAdReady()
|
public bool IsRewardAdReady()
|
||||||
{
|
{
|
||||||
return _adNetworks.Any(network => network.IsRewardedAvailable());
|
return _adNetworks.Any(network => network.IsRewardedAvailable());
|
||||||
|
@ -100,7 +100,9 @@ namespace WZ
|
||||||
AdPlayCountManager.IncrementAdPlayCount(AdsType.Rewarded);
|
AdPlayCountManager.IncrementAdPlayCount(AdsType.Rewarded);
|
||||||
CheckAndRefreshExpiredBids(AdsType.Rewarded);
|
CheckAndRefreshExpiredBids(AdsType.Rewarded);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 插屏广告
|
||||||
public bool IsInterstitialReady()
|
public bool IsInterstitialReady()
|
||||||
{
|
{
|
||||||
return _adNetworks.Any(network => network.IsInterstitialAvailable());
|
return _adNetworks.Any(network => network.IsInterstitialAvailable());
|
||||||
|
@ -151,6 +153,51 @@ namespace WZ
|
||||||
// 刷新其他类型广告
|
// 刷新其他类型广告
|
||||||
CheckAndRefreshExpiredBids(AdsType.Interstitial);
|
CheckAndRefreshExpiredBids(AdsType.Interstitial);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 横幅广告
|
||||||
|
public bool IsBannerAdReady()
|
||||||
|
{
|
||||||
|
return AdmobAdsManager.Instance.IsBannerAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowBanner()
|
||||||
|
{
|
||||||
|
AdsActionEvents.TrackAdPosition(AdsType.Interstitial, "");
|
||||||
|
if (IsBannerAdReady())
|
||||||
|
{
|
||||||
|
AdmobAdsManager.Instance.DisplayBanner();
|
||||||
|
AdPlayCountManager.IncrementAdPlayCount(AdsType.Banner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HideBanner()
|
||||||
|
{
|
||||||
|
AdmobAdsManager.Instance.HideBanner();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region 原生广告
|
||||||
|
public bool IsNativeAdReady()
|
||||||
|
{
|
||||||
|
return AdmobAdsManager.Instance.IsNativeAvailable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowNativeAd(NativeAdPosition position)
|
||||||
|
{
|
||||||
|
if (IsNativeAdReady())
|
||||||
|
{
|
||||||
|
AdmobAdsManager.Instance.DisplayNative(position);
|
||||||
|
AdPlayCountManager.IncrementAdPlayCount(AdsType.Native);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveNativeAd()
|
||||||
|
{
|
||||||
|
AdmobAdsManager.Instance.RemoveNative();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 开屏广告
|
#region 开屏广告
|
||||||
public bool IsSplashAvailable()
|
public bool IsSplashAvailable()
|
||||||
|
@ -197,7 +244,80 @@ namespace WZ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查并刷新过期竞价
|
/// <summary>
|
||||||
|
/// 广告看完回调
|
||||||
|
/// </summary>
|
||||||
|
public void OnRewardAdCallback(double price)
|
||||||
|
{
|
||||||
|
AdRewardCallback?.Invoke(price);
|
||||||
|
AdRewardCallback = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据IvRules判断是否可以展示插屏
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool IvRulesShow(IvType ivadType)
|
||||||
|
{
|
||||||
|
//1.获取远程配置
|
||||||
|
string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("IV_RULES");
|
||||||
|
if (string.IsNullOrEmpty(json))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//2.解析配置
|
||||||
|
var dates = JsonConvert.DeserializeObject<IvRulesData[]>(json);
|
||||||
|
if (dates == null && dates.Length == 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//3.获取IVADType对应的配置
|
||||||
|
IvRulesData ivRulesData = null;
|
||||||
|
foreach (var data in dates)
|
||||||
|
{
|
||||||
|
if (data.type == (int)ivadType)
|
||||||
|
{
|
||||||
|
ivRulesData = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ivRulesData == null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//4.判断skip(次安装跳过几次触发不展示广告)
|
||||||
|
int skipLevel = ivRulesData.skipLevel;
|
||||||
|
int currentSkipLevel = PlayerPrefsUtils.GetPlayerPrefsInt(IvRulesKey.KEY_SKIPLEVEL, 0);
|
||||||
|
if (currentSkipLevel < skipLevel)
|
||||||
|
{
|
||||||
|
LoggerUtils.Debug($"[SDK] skipLevel limit");
|
||||||
|
PlayerPrefsUtils.SavePlayerPrefsInt(IvRulesKey.KEY_SKIPLEVEL, currentSkipLevel + 1);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//5.判断overLevel(没跳过几次触发)
|
||||||
|
int overLevel = ivRulesData.overLevel;
|
||||||
|
int currentOverLevel = IvRulesConst.CurrentOverLevel;
|
||||||
|
if (currentOverLevel < overLevel)
|
||||||
|
{
|
||||||
|
LoggerUtils.Debug($"[SDK] overLevel limit");
|
||||||
|
IvRulesConst.CurrentOverLevel++;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//6.判断interval(广告时间间隔)
|
||||||
|
int interval = ivRulesData.interval;
|
||||||
|
long currentInterval = IvRulesConst.CurrentInterval;
|
||||||
|
long localTimestamp = TimeUtils.GetLocalTimestamp();
|
||||||
|
|
||||||
|
if (localTimestamp < currentInterval + (interval * 1000L))
|
||||||
|
{
|
||||||
|
LoggerUtils.Debug($"[SDK] interval limit");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 检查并刷新过期竞价
|
||||||
private void CheckAndRefreshExpiredBids(AdsType _adsType)
|
private void CheckAndRefreshExpiredBids(AdsType _adsType)
|
||||||
{
|
{
|
||||||
Dictionary<PlatformType, List<AdsType>> expiredBids = BidPlatformManager.Instance.GetExpiredBids();
|
Dictionary<PlatformType, List<AdsType>> expiredBids = BidPlatformManager.Instance.GetExpiredBids();
|
||||||
|
@ -327,78 +447,6 @@ namespace WZ
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
/// <summary>
|
|
||||||
/// 广告看完回调
|
|
||||||
/// </summary>
|
|
||||||
public void OnRewardAdCallback(double price)
|
|
||||||
{
|
|
||||||
AdRewardCallback?.Invoke(price);
|
|
||||||
AdRewardCallback = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 根据IvRules判断是否可以展示插屏
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool IvRulesShow(IvType ivadType)
|
|
||||||
{
|
|
||||||
//1.获取远程配置
|
|
||||||
string json = FireBaseRemoteConfigManager.Instance.GetRemoteConfigString("IV_RULES");
|
|
||||||
if (string.IsNullOrEmpty(json))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
//2.解析配置
|
|
||||||
var dates = JsonConvert.DeserializeObject<IvRulesData[]>(json);
|
|
||||||
if (dates == null && dates.Length == 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
//3.获取IVADType对应的配置
|
|
||||||
IvRulesData ivRulesData = null;
|
|
||||||
foreach (var data in dates)
|
|
||||||
{
|
|
||||||
if (data.type == (int)ivadType)
|
|
||||||
{
|
|
||||||
ivRulesData = data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ivRulesData == null)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
//4.判断skip(次安装跳过几次触发不展示广告)
|
|
||||||
int skipLevel = ivRulesData.skipLevel;
|
|
||||||
int currentSkipLevel = PlayerPrefsUtils.GetPlayerPrefsInt(IvRulesKey.KEY_SKIPLEVEL, 0);
|
|
||||||
if (currentSkipLevel < skipLevel)
|
|
||||||
{
|
|
||||||
LoggerUtils.Debug($"[SDK] skipLevel limit");
|
|
||||||
PlayerPrefsUtils.SavePlayerPrefsInt(IvRulesKey.KEY_SKIPLEVEL, currentSkipLevel + 1);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
//5.判断overLevel(没跳过几次触发)
|
|
||||||
int overLevel = ivRulesData.overLevel;
|
|
||||||
int currentOverLevel = IvRulesConst.CurrentOverLevel;
|
|
||||||
if (currentOverLevel < overLevel)
|
|
||||||
{
|
|
||||||
LoggerUtils.Debug($"[SDK] overLevel limit");
|
|
||||||
IvRulesConst.CurrentOverLevel++;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//6.判断interval(广告时间间隔)
|
|
||||||
int interval = ivRulesData.interval;
|
|
||||||
long currentInterval = IvRulesConst.CurrentInterval;
|
|
||||||
long localTimestamp = TimeUtils.GetLocalTimestamp();
|
|
||||||
|
|
||||||
if (localTimestamp < currentInterval + (interval * 1000L))
|
|
||||||
{
|
|
||||||
LoggerUtils.Debug($"[SDK] interval limit");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue