You've already forked Commercialization.tapadn
Fix TapADN ad lifecycle callbacks
This commit is contained in:
@@ -7,6 +7,7 @@ public sealed class TapadnInteractionPlayer : ADPlayer, IDirichletInterstitialAu
|
||||
{
|
||||
private DirichletAdNative _adNative;
|
||||
private DirichletInterstitialAd _loadedAd;
|
||||
private bool _showSettled;
|
||||
|
||||
public override int MaxLoadAttempts => TapadnAdController.CurrentOptions?.InterstitialMaxLoadAttempts ?? base.MaxLoadAttempts;
|
||||
public override float LoadRetryDelaySeconds => Math.Max(0f, (TapadnAdController.CurrentOptions?.InterstitialLoadRetryDelayMs ?? 500) / 1000f);
|
||||
@@ -63,6 +64,7 @@ public sealed class TapadnInteractionPlayer : ADPlayer, IDirichletInterstitialAu
|
||||
_loadedAd = ad;
|
||||
_loadedAd.Shown += OnManualShown;
|
||||
_loadedAd.Clicked += OnManualClicked;
|
||||
_loadedAd.ShowFailed += OnManualShowFailed;
|
||||
_loadedAd.Closed += OnManualClosed;
|
||||
curState = 2;
|
||||
Debug.Log($"[TapADN] Interstitial loaded. slot={Key}");
|
||||
@@ -78,6 +80,7 @@ public sealed class TapadnInteractionPlayer : ADPlayer, IDirichletInterstitialAu
|
||||
{
|
||||
adListener.onClose = onClose;
|
||||
adListener.onVideoComplete = onVideoComplete;
|
||||
_showSettled = false;
|
||||
curState = 0;
|
||||
|
||||
if (UseAutoLoad())
|
||||
@@ -88,12 +91,18 @@ public sealed class TapadnInteractionPlayer : ADPlayer, IDirichletInterstitialAu
|
||||
|
||||
if (_loadedAd == null || !_loadedAd.Show())
|
||||
{
|
||||
adListener.OnShowError();
|
||||
OnError(new DirichletError("show_failed", "ShowInterstitialAd returned false"));
|
||||
}
|
||||
}
|
||||
|
||||
public void OnError(DirichletError error)
|
||||
{
|
||||
if (_showSettled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_showSettled = true;
|
||||
curState = 0;
|
||||
Debug.LogError($"[TapADN] Interstitial show failed. code={error?.Code}, message={error?.Message}");
|
||||
adListener.OnShowError();
|
||||
@@ -106,6 +115,12 @@ public sealed class TapadnInteractionPlayer : ADPlayer, IDirichletInterstitialAu
|
||||
|
||||
public void OnAdClose()
|
||||
{
|
||||
if (_showSettled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_showSettled = true;
|
||||
adListener.OnAdClose();
|
||||
adListener.OnShowComplete();
|
||||
}
|
||||
@@ -128,6 +143,11 @@ public sealed class TapadnInteractionPlayer : ADPlayer, IDirichletInterstitialAu
|
||||
{
|
||||
}
|
||||
|
||||
private void OnManualShowFailed(DirichletError error)
|
||||
{
|
||||
OnError(error);
|
||||
}
|
||||
|
||||
private void OnManualClosed()
|
||||
{
|
||||
_loadedAd?.Destroy();
|
||||
|
||||
Reference in New Issue
Block a user