修复bigo广告源提前关闭广告后获取奖励问题
This commit is contained in:
parent
33837645b5
commit
1a5d0ac88c
|
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using BigoAds.Scripts.Api;
|
using BigoAds.Scripts.Api;
|
||||||
|
using NUnit.Framework.Constraints;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -25,18 +26,19 @@ namespace WZ
|
||||||
|
|
||||||
private float _rvStartLoadTime = 0;
|
private float _rvStartLoadTime = 0;
|
||||||
private float _ivStartLoadTime = 0;
|
private float _ivStartLoadTime = 0;
|
||||||
|
private bool _receivedReward = false;
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
LoggerUtils.Debug("[Bigo] sdk init start"+_bigo_app_id+" rvid:"+_rewardedAdUnits+" ivid:"+_interstitialAdUnits);
|
LoggerUtils.Debug("[Bigo] sdk init start" + _bigo_app_id + " rvid:" + _rewardedAdUnits + " ivid:" + _interstitialAdUnits);
|
||||||
if (string.IsNullOrEmpty(_bigo_app_id)|| _initialized) return;
|
if (string.IsNullOrEmpty(_bigo_app_id) || _initialized) return;
|
||||||
BigoAdSdk.OnInitFinish += () =>
|
BigoAdSdk.OnInitFinish += () =>
|
||||||
{
|
{
|
||||||
LoggerUtils.Debug($"[Bigo] sdk init success");
|
LoggerUtils.Debug($"[Bigo] sdk init success");
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
LoadRewarded();
|
LoadRewarded();
|
||||||
LoadInterstitial();
|
LoadInterstitial();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var config = new BigoAdConfig.Builder()
|
var config = new BigoAdConfig.Builder()
|
||||||
|
|
@ -72,12 +74,18 @@ namespace WZ
|
||||||
private void OnRewardedAdDismissed(string adUnitId,double revenue)
|
private void OnRewardedAdDismissed(string adUnitId,double revenue)
|
||||||
{
|
{
|
||||||
AdsActionEvents.TrackAdClosed(Platfrom,ClientName, adUnitId, AdsType.Rewarded, _rvPos, revenue);
|
AdsActionEvents.TrackAdClosed(Platfrom,ClientName, adUnitId, AdsType.Rewarded, _rvPos, revenue);
|
||||||
_rvCloseCallback?.Invoke(true,revenue);
|
_rvCloseCallback?.Invoke(_receivedReward,revenue);
|
||||||
_rvCloseCallback = null;
|
_rvCloseCallback = null;
|
||||||
|
_receivedReward = false;
|
||||||
LoadRewarded();
|
LoadRewarded();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnRewardEarnReward(bool reward)
|
||||||
|
{
|
||||||
|
_receivedReward = true;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnRewardedAdError(string adUnitId, int code, string msg)
|
private void OnRewardedAdError(string adUnitId, int code, string msg)
|
||||||
{
|
{
|
||||||
AdsActionEvents.TrackAdFailToShow(Platfrom, AdsType.Rewarded, msg, _rvPos);
|
AdsActionEvents.TrackAdFailToShow(Platfrom, AdsType.Rewarded, msg, _rvPos);
|
||||||
|
|
@ -104,7 +112,8 @@ namespace WZ
|
||||||
onAdShowed: OnRewardedAdShowed,
|
onAdShowed: OnRewardedAdShowed,
|
||||||
onAdDismissed: OnRewardedAdDismissed,
|
onAdDismissed: OnRewardedAdDismissed,
|
||||||
onAdError: OnRewardedAdError,
|
onAdError: OnRewardedAdError,
|
||||||
onAdClicked: OnRewardedAdClicked
|
onAdClicked: OnRewardedAdClicked,
|
||||||
|
onEarnRewarded: OnRewardEarnReward
|
||||||
);
|
);
|
||||||
_rvStartLoadTime = Time.realtimeSinceStartup;
|
_rvStartLoadTime = Time.realtimeSinceStartup;
|
||||||
// todo 暂时支持一个广告位,后续支持多个广告位
|
// todo 暂时支持一个广告位,后续支持多个广告位
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,12 @@ namespace WZ
|
||||||
Action<string> onAdShowed = null,
|
Action<string> onAdShowed = null,
|
||||||
Action<string,double> onAdDismissed = null,
|
Action<string,double> onAdDismissed = null,
|
||||||
Action<string, int, string> onAdError = null,
|
Action<string, int, string> onAdError = null,
|
||||||
Action<string,double> onAdClicked = null)
|
Action<string,double> onAdClicked = null,
|
||||||
|
Action<bool> onEarnRewarded = null)
|
||||||
{
|
{
|
||||||
foreach (var adUnitId in adUnitIds)
|
foreach (var adUnitId in adUnitIds)
|
||||||
{
|
{
|
||||||
CreateRewardedAd(adUnitId, onAdLoaded, onAdLoadFailed, onAdShowed, onAdDismissed, onAdError, onAdClicked);
|
CreateRewardedAd(adUnitId, onAdLoaded, onAdLoadFailed, onAdShowed, onAdDismissed, onAdError, onAdClicked, onEarnRewarded);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -32,7 +33,8 @@ namespace WZ
|
||||||
Action<string> onAdShowed,
|
Action<string> onAdShowed,
|
||||||
Action<string, double> onAdDismissed,
|
Action<string, double> onAdDismissed,
|
||||||
Action<string, int, string> onAdError,
|
Action<string, int, string> onAdError,
|
||||||
Action<string,double> onAdClicked)
|
Action<string,double> onAdClicked,
|
||||||
|
Action<bool> onEarnRewarded = null)
|
||||||
{
|
{
|
||||||
if (_rewardedAds.ContainsKey(adUnitId))
|
if (_rewardedAds.ContainsKey(adUnitId))
|
||||||
{
|
{
|
||||||
|
|
@ -53,7 +55,13 @@ namespace WZ
|
||||||
AdsKeyEvents.Instance.LogAdFPUEvents(AdsType.Rewarded);
|
AdsKeyEvents.Instance.LogAdFPUEvents(AdsType.Rewarded);
|
||||||
onAdLoaded?.Invoke(adUnitId);
|
onAdLoaded?.Invoke(adUnitId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
rewardedAd.OnUserEarnedReward += () =>
|
||||||
|
{
|
||||||
|
LoggerUtils.Debug("[Bigo] Rewarded-[interaction]: {adUnitId} earn reward");
|
||||||
|
onEarnRewarded?.Invoke(true);
|
||||||
|
};
|
||||||
|
|
||||||
rewardedAd.OnLoadFailed += ((code, msg) =>
|
rewardedAd.OnLoadFailed += ((code, msg) =>
|
||||||
{
|
{
|
||||||
_retryCounters[adUnitId]++;
|
_retryCounters[adUnitId]++;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue