parent
07818bd40e
commit
aced9b0d1d
|
|
@ -124,6 +124,7 @@ namespace Guru
|
||||||
public override void RequestInterstitialAD()
|
public override void RequestInterstitialAD()
|
||||||
{
|
{
|
||||||
if (!IsInitialized) return;
|
if (!IsInitialized) return;
|
||||||
|
if (IsIadsLoading) return;
|
||||||
OnChannelLoadInterstitialAD();
|
OnChannelLoadInterstitialAD();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -154,6 +155,7 @@ namespace Guru
|
||||||
public override void RequestRewardedAD()
|
public override void RequestRewardedAD()
|
||||||
{
|
{
|
||||||
if (!IsInitialized) return;
|
if (!IsInitialized) return;
|
||||||
|
if (IsRadsLoading) return;
|
||||||
OnChannelLoadRewardAD();
|
OnChannelLoadRewardAD();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -342,11 +342,15 @@ namespace Guru
|
||||||
private int _interstitialRetryAttempt;
|
private int _interstitialRetryAttempt;
|
||||||
protected float _iadsLoadStartTime;
|
protected float _iadsLoadStartTime;
|
||||||
private Action _interstitialDismissAction;
|
private Action _interstitialDismissAction;
|
||||||
|
protected bool _isIadsLoading = false;
|
||||||
|
public bool IsIadsLoading => _isIadsLoading;
|
||||||
|
|
||||||
public virtual void RequestInterstitialAD()
|
public virtual void RequestInterstitialAD()
|
||||||
{
|
{
|
||||||
if (!CanLoadAds())
|
if (!CanLoadAds()) return;
|
||||||
return;
|
|
||||||
|
if(_isIadsLoading) return;
|
||||||
|
_isIadsLoading = true;
|
||||||
|
|
||||||
LoadMaxInterstitial();
|
LoadMaxInterstitial();
|
||||||
}
|
}
|
||||||
|
|
@ -368,9 +372,7 @@ namespace Guru
|
||||||
|
|
||||||
public bool IsInterstitialADReady()
|
public bool IsInterstitialADReady()
|
||||||
{
|
{
|
||||||
if (!IsInitialized)
|
if (!IsInitialized) return false;
|
||||||
return false;
|
|
||||||
|
|
||||||
return MaxSdk.IsInterstitialReady(GetInterstitialID());
|
return MaxSdk.IsInterstitialReady(GetInterstitialID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -398,11 +400,12 @@ namespace Guru
|
||||||
_interstitialDismissAction = dismissAction;
|
_interstitialDismissAction = dismissAction;
|
||||||
MaxSdk.ShowInterstitial(GetInterstitialID());
|
MaxSdk.ShowInterstitial(GetInterstitialID());
|
||||||
|
|
||||||
RequestInterstitialAD(); // 直接加载下一个广告
|
// RequestInterstitialAD(); // 直接加载下一个广告
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnInterstitialLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
protected virtual void OnInterstitialLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||||
{
|
{
|
||||||
|
_isIadsLoading = false;
|
||||||
// Interstitial ad is ready to be shown. MaxSdk.IsInterstitialReady(interstitialAdUnitId) will now return 'true'
|
// Interstitial ad is ready to be shown. MaxSdk.IsInterstitialReady(interstitialAdUnitId) will now return 'true'
|
||||||
// Reset retry attempt
|
// Reset retry attempt
|
||||||
// Analytics.ADIadsLoaded(adUnitId, GetAdsLoadDuration(ref _iadsLoadStartTime), _iadsCategory);
|
// Analytics.ADIadsLoaded(adUnitId, GetAdsLoadDuration(ref _iadsLoadStartTime), _iadsCategory);
|
||||||
|
|
@ -415,6 +418,7 @@ namespace Guru
|
||||||
|
|
||||||
protected virtual void OnInterstitialFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
|
protected virtual void OnInterstitialFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
|
||||||
{
|
{
|
||||||
|
_isIadsLoading = false;
|
||||||
// Interstitial ad failed to load
|
// Interstitial ad failed to load
|
||||||
// We recommend retrying with exponentially higher delays up to a maximum delay (in this case 64 seconds)
|
// We recommend retrying with exponentially higher delays up to a maximum delay (in this case 64 seconds)
|
||||||
this.LogError(
|
this.LogError(
|
||||||
|
|
@ -477,11 +481,15 @@ namespace Guru
|
||||||
private Action _rewardAction;
|
private Action _rewardAction;
|
||||||
private Action<string> _failAction;
|
private Action<string> _failAction;
|
||||||
private Action _dismissAction;
|
private Action _dismissAction;
|
||||||
|
protected bool _isRadsLoading = false;
|
||||||
|
public bool IsRadsLoading => _isRadsLoading;
|
||||||
|
|
||||||
public virtual void RequestRewardedAD()
|
public virtual void RequestRewardedAD()
|
||||||
{
|
{
|
||||||
if (!IsInitialized)
|
if (!CanLoadAds()) return;
|
||||||
return;
|
|
||||||
|
if (_isRadsLoading) return;
|
||||||
|
_isRadsLoading = true;
|
||||||
|
|
||||||
LoadMaxRewardAd();
|
LoadMaxRewardAd();
|
||||||
}
|
}
|
||||||
|
|
@ -492,6 +500,8 @@ namespace Guru
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void LoadMaxRewardAd(string unitId = "")
|
protected void LoadMaxRewardAd(string unitId = "")
|
||||||
{
|
{
|
||||||
|
if (IsRadsLoading) return;
|
||||||
|
|
||||||
OnLoadRads();
|
OnLoadRads();
|
||||||
var id = GetRewardedVideoID();
|
var id = GetRewardedVideoID();
|
||||||
Analytics.ADRadsLoad(AdParams.Build(id)); // 上报打点
|
Analytics.ADRadsLoad(AdParams.Build(id)); // 上报打点
|
||||||
|
|
@ -539,11 +549,13 @@ namespace Guru
|
||||||
_dismissAction = dismissAction;
|
_dismissAction = dismissAction;
|
||||||
MaxSdk.ShowRewardedAd(GetRewardedVideoID());
|
MaxSdk.ShowRewardedAd(GetRewardedVideoID());
|
||||||
|
|
||||||
RequestRewardedAD();
|
// RequestRewardedAD();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnRewardedAdLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
protected virtual void OnRewardedAdLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo)
|
||||||
{
|
{
|
||||||
|
_isRadsLoading = false;
|
||||||
|
|
||||||
// Rewarded ad is ready to be shown. MaxSdk.IsRewardedAdReady(rewardedAdUnitId) will now return 'true'
|
// Rewarded ad is ready to be shown. MaxSdk.IsRewardedAdReady(rewardedAdUnitId) will now return 'true'
|
||||||
// Reset retry attempt
|
// Reset retry attempt
|
||||||
// this.Log("OnRewardedAdLoadedEvent");
|
// this.Log("OnRewardedAdLoadedEvent");
|
||||||
|
|
@ -557,6 +569,8 @@ namespace Guru
|
||||||
|
|
||||||
protected virtual void OnRewardedAdFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
|
protected virtual void OnRewardedAdFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo errorInfo)
|
||||||
{
|
{
|
||||||
|
_isRadsLoading = false;
|
||||||
|
|
||||||
// Rewarded ad failed to load
|
// Rewarded ad failed to load
|
||||||
// We recommend retrying with exponentially higher delays up to a maximum delay (in this case 64 seconds)
|
// We recommend retrying with exponentially higher delays up to a maximum delay (in this case 64 seconds)
|
||||||
this.LogError(
|
this.LogError(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue