提交修改
This commit is contained in:
co-authored by
changyunjia
parent
d4442fc21f
commit
3ac4fe0cd0
+1
-1
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using KwaiAds.Scripts.Common;
|
||||
|
||||
namespace KwaiAds.Scripts.Api
|
||||
|
||||
Vendored
Regular → Executable
+21
-21
@@ -1,21 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public interface IKwaiAdListener
|
||||
{
|
||||
void OnLoaded(string unitId, string price);
|
||||
|
||||
void OnLoadFailed(string unitId, int code, string msg);
|
||||
|
||||
void OnShow();
|
||||
|
||||
void OnShowFailed(int code, string msg);
|
||||
|
||||
void OnClick();
|
||||
|
||||
void OnClosed();
|
||||
|
||||
void OnReward();
|
||||
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public interface IKwaiAdListener
|
||||
{
|
||||
void OnLoaded(string unitId, string price);
|
||||
|
||||
void OnLoadFailed(string unitId, int code, string msg);
|
||||
|
||||
void OnShow();
|
||||
|
||||
void OnShowFailed(int code, string msg);
|
||||
|
||||
void OnClick();
|
||||
|
||||
void OnClosed();
|
||||
|
||||
void OnReward();
|
||||
|
||||
}
|
||||
|
||||
Vendored
Regular → Executable
+3
-3
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"name": "KwaiAds"
|
||||
}
|
||||
{
|
||||
"name": "KwaiAds"
|
||||
}
|
||||
|
||||
+66
-66
@@ -1,66 +1,66 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class KwaiAdsMgr
|
||||
{
|
||||
public static void Init(string appId, string token, bool isDebug, Action<bool, int, string> initCallBack)
|
||||
{
|
||||
bool debug = isDebug; // Whether in debug mode. Plsease set to false when in release build.
|
||||
var kwaiAdConfig = new KwaiAds.Scripts.Api.KwaiAdConfig.Builder()
|
||||
.SetAppId(appId) // ±ØÌî
|
||||
.SetToken(token) // ±ØÌî
|
||||
.SetAppName("")
|
||||
.SetAppDomain("")
|
||||
.SetAppStoreUrl("")
|
||||
.SetDebugLog(debug)
|
||||
.Build();
|
||||
KwaiAds.Scripts.Api.KwaiAdsSdk.Initialize(kwaiAdConfig, new InitResultCallbackImpl(initCallBack));
|
||||
}
|
||||
|
||||
class InitResultCallbackImpl : KwaiAds.Scripts.Api.InitResultCallback
|
||||
{
|
||||
private Action<bool, int, string> _initCallBack;
|
||||
|
||||
public InitResultCallbackImpl(Action<bool, int, string> callBack)
|
||||
{
|
||||
_initCallBack = callBack;
|
||||
}
|
||||
|
||||
public void OnFail(int code, string msg)
|
||||
{
|
||||
_initCallBack?.Invoke(false, code, msg);
|
||||
KwaiLog.Error($"#Kwai InitResultCallback code:{code}, msg: {msg}");
|
||||
}
|
||||
|
||||
public void OnSuccess()
|
||||
{
|
||||
_initCallBack?.Invoke(true, 0, "");
|
||||
KwaiLog.Log($"#Kwai InitResultCallback OnSuccess.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class KwaiLog
|
||||
{
|
||||
public static bool isShow = true;
|
||||
|
||||
public static void Log(string msg)
|
||||
{
|
||||
if (isShow)
|
||||
{
|
||||
Debug.Log(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Error(string msg)
|
||||
{
|
||||
if (isShow)
|
||||
{
|
||||
Debug.LogError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class KwaiAdsMgr
|
||||
{
|
||||
public static void Init(string appId, string token, bool isDebug, Action<bool, int, string> initCallBack)
|
||||
{
|
||||
bool debug = isDebug; // Whether in debug mode. Plsease set to false when in release build.
|
||||
var kwaiAdConfig = new KwaiAds.Scripts.Api.KwaiAdConfig.Builder()
|
||||
.SetAppId(appId) // ±ØÌî
|
||||
.SetToken(token) // ±ØÌî
|
||||
.SetAppName("")
|
||||
.SetAppDomain("")
|
||||
.SetAppStoreUrl("")
|
||||
.SetDebugLog(debug)
|
||||
.Build();
|
||||
KwaiAds.Scripts.Api.KwaiAdsSdk.Initialize(kwaiAdConfig, new InitResultCallbackImpl(initCallBack));
|
||||
}
|
||||
|
||||
class InitResultCallbackImpl : KwaiAds.Scripts.Api.InitResultCallback
|
||||
{
|
||||
private Action<bool, int, string> _initCallBack;
|
||||
|
||||
public InitResultCallbackImpl(Action<bool, int, string> callBack)
|
||||
{
|
||||
_initCallBack = callBack;
|
||||
}
|
||||
|
||||
public void OnFail(int code, string msg)
|
||||
{
|
||||
_initCallBack?.Invoke(false, code, msg);
|
||||
KwaiLog.Error($"#Kwai InitResultCallback code:{code}, msg: {msg}");
|
||||
}
|
||||
|
||||
public void OnSuccess()
|
||||
{
|
||||
_initCallBack?.Invoke(true, 0, "");
|
||||
KwaiLog.Log($"#Kwai InitResultCallback OnSuccess.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class KwaiLog
|
||||
{
|
||||
public static bool isShow = true;
|
||||
|
||||
public static void Log(string msg)
|
||||
{
|
||||
if (isShow)
|
||||
{
|
||||
Debug.Log(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Error(string msg)
|
||||
{
|
||||
if (isShow)
|
||||
{
|
||||
Debug.LogError(msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+133
-133
@@ -1,133 +1,133 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using KwaiAds.Scripts.Api;
|
||||
using KwaiAds.Scripts.Api.Interstitial;
|
||||
using UnityEngine;
|
||||
|
||||
public class KwaiInterAd
|
||||
{
|
||||
private IInterstitialAdController _kwaiInter;
|
||||
private string _unitId;
|
||||
private IKwaiAdListener _kwaiAdListener;
|
||||
|
||||
public IKwaiAdListener KwaiAdListener => _kwaiAdListener;
|
||||
|
||||
public KwaiInterAd(string unitId, IKwaiAdListener adListener)
|
||||
{
|
||||
_unitId = unitId;
|
||||
_kwaiAdListener = adListener;
|
||||
}
|
||||
|
||||
public void Load(string ecpmPrice = "0.01")
|
||||
{
|
||||
// 获取每次load都需要获取新的KwaiInterstitialAdController
|
||||
if (_kwaiInter != null)
|
||||
{
|
||||
_kwaiInter.Destroy();
|
||||
_kwaiInter = null;
|
||||
}
|
||||
_kwaiInter = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getInterstitialAdController();
|
||||
// 构建KwaiInterstitialAdRequest
|
||||
KwaiInterstitialAdRequest interstitialRewardAdRequest = new KwaiInterstitialAdRequest(_unitId); // tagId必填
|
||||
// 选填, 可以设置低价 单位是$(美元,ecpm)
|
||||
interstitialRewardAdRequest.ExtParams[Constants.Request.BID_FLOOR_PRICE] = ecpmPrice;
|
||||
// 加载过程接受三个参数,
|
||||
// - KwaiInterstitialAdRequest 配置请求参数
|
||||
// - IInterstitialAdListener 回调为插页点击、曝光状态
|
||||
// - IInterstitialAdLoadListener 回调为插页加载状态
|
||||
_kwaiInter.Load(interstitialRewardAdRequest, new InterstitialAdListener(this), new InterstitialAdLoadListener(this));
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
if (IsReady())
|
||||
{
|
||||
_kwaiInter.Show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsReady()
|
||||
{
|
||||
return _kwaiInter != null && _kwaiInter.IsReady();
|
||||
}
|
||||
|
||||
public void NotifyWin(string minWinPrice)
|
||||
{
|
||||
//_kwaiInter?.NotifyWin();//报错暂时屏蔽
|
||||
_kwaiInter?.NotifyWin(minWinPrice);
|
||||
}
|
||||
|
||||
public void NotifyLoss(string winPrice)
|
||||
{
|
||||
//_kwaiInter?.NotifyLoss();
|
||||
_kwaiInter?.NotifyLoss(winPrice);
|
||||
}
|
||||
|
||||
private class InterstitialAdListener : IInterstitialAdListener
|
||||
{
|
||||
private KwaiInterAd _kwaiInterAd;
|
||||
|
||||
public InterstitialAdListener(KwaiInterAd interAd)
|
||||
{
|
||||
_kwaiInterAd = interAd;
|
||||
}
|
||||
|
||||
public void OnAdClick()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClick");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnClick();
|
||||
}
|
||||
|
||||
public void OnAdClose()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClose");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnClosed();
|
||||
}
|
||||
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdPlayComplete");
|
||||
}
|
||||
|
||||
public void OnAdShow()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShow");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnShow();
|
||||
}
|
||||
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShowFailed code = {code}, msg = {msg}");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnShowFailed(code, msg);
|
||||
}
|
||||
}
|
||||
|
||||
private class InterstitialAdLoadListener : IInterstitialAdLoadListener
|
||||
{
|
||||
private KwaiInterAd _kwaiInterAd;
|
||||
public InterstitialAdLoadListener(KwaiInterAd interAd)
|
||||
{
|
||||
_kwaiInterAd = interAd;
|
||||
}
|
||||
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadFailed trackId = {trackId}, code = {code}, msg = {msg}");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnLoadFailed(trackId, code, msg);
|
||||
}
|
||||
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadStart trackId = {trackId}");
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadSuccess trackId = {trackId}, price = {price}");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnLoaded(trackId, price);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using KwaiAds.Scripts.Api;
|
||||
using KwaiAds.Scripts.Api.Interstitial;
|
||||
using UnityEngine;
|
||||
|
||||
public class KwaiInterAd
|
||||
{
|
||||
private IInterstitialAdController _kwaiInter;
|
||||
private string _unitId;
|
||||
private IKwaiAdListener _kwaiAdListener;
|
||||
|
||||
public IKwaiAdListener KwaiAdListener => _kwaiAdListener;
|
||||
|
||||
public KwaiInterAd(string unitId, IKwaiAdListener adListener)
|
||||
{
|
||||
_unitId = unitId;
|
||||
_kwaiAdListener = adListener;
|
||||
}
|
||||
|
||||
public void Load(string ecpmPrice = "0.01")
|
||||
{
|
||||
// 获取每次load都需要获取新的KwaiInterstitialAdController
|
||||
if (_kwaiInter != null)
|
||||
{
|
||||
_kwaiInter.Destroy();
|
||||
_kwaiInter = null;
|
||||
}
|
||||
_kwaiInter = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getInterstitialAdController();
|
||||
// 构建KwaiInterstitialAdRequest
|
||||
KwaiInterstitialAdRequest interstitialRewardAdRequest = new KwaiInterstitialAdRequest(_unitId); // tagId必填
|
||||
// 选填, 可以设置低价 单位是$(美元,ecpm)
|
||||
interstitialRewardAdRequest.ExtParams[Constants.Request.BID_FLOOR_PRICE] = ecpmPrice;
|
||||
// 加载过程接受三个参数,
|
||||
// - KwaiInterstitialAdRequest 配置请求参数
|
||||
// - IInterstitialAdListener 回调为插页点击、曝光状态
|
||||
// - IInterstitialAdLoadListener 回调为插页加载状态
|
||||
_kwaiInter.Load(interstitialRewardAdRequest, new InterstitialAdListener(this), new InterstitialAdLoadListener(this));
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
if (IsReady())
|
||||
{
|
||||
_kwaiInter.Show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsReady()
|
||||
{
|
||||
return _kwaiInter != null && _kwaiInter.IsReady();
|
||||
}
|
||||
|
||||
public void NotifyWin(string minWinPrice)
|
||||
{
|
||||
//_kwaiInter?.NotifyWin();//报错暂时屏蔽
|
||||
_kwaiInter?.NotifyWin(minWinPrice);
|
||||
}
|
||||
|
||||
public void NotifyLoss(string winPrice)
|
||||
{
|
||||
//_kwaiInter?.NotifyLoss();
|
||||
_kwaiInter?.NotifyLoss(winPrice);
|
||||
}
|
||||
|
||||
private class InterstitialAdListener : IInterstitialAdListener
|
||||
{
|
||||
private KwaiInterAd _kwaiInterAd;
|
||||
|
||||
public InterstitialAdListener(KwaiInterAd interAd)
|
||||
{
|
||||
_kwaiInterAd = interAd;
|
||||
}
|
||||
|
||||
public void OnAdClick()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClick");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnClick();
|
||||
}
|
||||
|
||||
public void OnAdClose()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClose");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnClosed();
|
||||
}
|
||||
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdPlayComplete");
|
||||
}
|
||||
|
||||
public void OnAdShow()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShow");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnShow();
|
||||
}
|
||||
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShowFailed code = {code}, msg = {msg}");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnShowFailed(code, msg);
|
||||
}
|
||||
}
|
||||
|
||||
private class InterstitialAdLoadListener : IInterstitialAdLoadListener
|
||||
{
|
||||
private KwaiInterAd _kwaiInterAd;
|
||||
public InterstitialAdLoadListener(KwaiInterAd interAd)
|
||||
{
|
||||
_kwaiInterAd = interAd;
|
||||
}
|
||||
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadFailed trackId = {trackId}, code = {code}, msg = {msg}");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnLoadFailed(trackId, code, msg);
|
||||
}
|
||||
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadStart trackId = {trackId}");
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadSuccess trackId = {trackId}, price = {price}");
|
||||
_kwaiInterAd?.KwaiAdListener?.OnLoaded(trackId, price);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+139
-139
@@ -1,139 +1,139 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using KwaiAds.Scripts.Api.Reward;
|
||||
using KwaiAds.Scripts.Api;
|
||||
using UnityEngine;
|
||||
|
||||
public class KwaiVideoAd
|
||||
{
|
||||
private KwaiAds.Scripts.Api.Reward.IRewardAdController _kwaiReward;
|
||||
private string _unitId;
|
||||
private IKwaiAdListener _kwaiAdListener;
|
||||
|
||||
public IKwaiAdListener KwaiAdListener => _kwaiAdListener;
|
||||
|
||||
public KwaiVideoAd(string unitId, IKwaiAdListener adListener)
|
||||
{
|
||||
_unitId = unitId;
|
||||
_kwaiAdListener = adListener;
|
||||
}
|
||||
|
||||
public void Load(string ecpmPrice = "0.01")
|
||||
{
|
||||
if(_kwaiReward != null)
|
||||
{
|
||||
_kwaiReward.Destroy();
|
||||
_kwaiReward = null;
|
||||
}
|
||||
|
||||
_kwaiReward = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getRewardAdController();
|
||||
|
||||
// 构建KwaiRewardAdRequest
|
||||
KwaiRewardAdRequest kwaiRewardAdRequest = new KwaiRewardAdRequest(_unitId);
|
||||
// 选填, 可以设置低价 单位是$(美元,ecpm)
|
||||
kwaiRewardAdRequest.ExtParams[Constants.Request.BID_FLOOR_PRICE] = ecpmPrice;
|
||||
// 加载过程接受三个参数,
|
||||
// - KwaiRewardAdRequest 配置请求参数
|
||||
// - IRewardAdListener实现类,回调为激励
|
||||
_kwaiReward.Load(kwaiRewardAdRequest, new RewardAdListener(this), new RewardAdLoadListener(this));
|
||||
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
if(IsReady())
|
||||
{
|
||||
_kwaiReward.Show();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReady()
|
||||
{
|
||||
return _kwaiReward != null && _kwaiReward.IsReady();
|
||||
}
|
||||
|
||||
public void NotifyWin(string minWinPrice)
|
||||
{
|
||||
//_kwaiReward?.NotifyWin(); //报错暂时屏蔽
|
||||
_kwaiReward?.NotifyWin(minWinPrice);
|
||||
}
|
||||
|
||||
public void NotifyLoss(string winPrice)
|
||||
{
|
||||
//_kwaiReward?.NotifyLoss();
|
||||
_kwaiReward?.NotifyLoss(winPrice);
|
||||
}
|
||||
|
||||
|
||||
private class RewardAdListener : IRewardAdListener
|
||||
{
|
||||
private KwaiVideoAd _kwaiVideoAd;
|
||||
|
||||
public RewardAdListener(KwaiVideoAd videoAd)
|
||||
{
|
||||
_kwaiVideoAd = videoAd;
|
||||
}
|
||||
|
||||
public void OnAdClick()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClick");
|
||||
_kwaiVideoAd.KwaiAdListener.OnClick();
|
||||
}
|
||||
|
||||
public void OnAdClose()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClose");
|
||||
_kwaiVideoAd.KwaiAdListener.OnClosed();
|
||||
}
|
||||
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdPlayComplete");
|
||||
}
|
||||
|
||||
public void OnAdShow()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShow");
|
||||
_kwaiVideoAd.KwaiAdListener.OnShow();
|
||||
}
|
||||
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShowFailed, code = {code}, msg = {msg}");
|
||||
_kwaiVideoAd.KwaiAdListener.OnShowFailed(code, msg);
|
||||
}
|
||||
|
||||
public void OnRewardEarned()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnRewardEarned");
|
||||
_kwaiVideoAd.KwaiAdListener.OnReward();
|
||||
}
|
||||
}
|
||||
|
||||
private class RewardAdLoadListener : IRewardAdLoadListener
|
||||
{
|
||||
private KwaiVideoAd _kwaiVideoAd;
|
||||
|
||||
public RewardAdLoadListener(KwaiVideoAd videoAd)
|
||||
{
|
||||
_kwaiVideoAd = videoAd;
|
||||
}
|
||||
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadFailed, trackId = {trackId}, code = {code}, msg = {msg}");
|
||||
_kwaiVideoAd.KwaiAdListener.OnLoadFailed(trackId, code, msg);
|
||||
}
|
||||
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadStart, trackId = {trackId}");
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadSuccess, trackId = {trackId}, price = {price}");
|
||||
_kwaiVideoAd.KwaiAdListener.OnLoaded(trackId, price);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using KwaiAds.Scripts.Api.Reward;
|
||||
using KwaiAds.Scripts.Api;
|
||||
using UnityEngine;
|
||||
|
||||
public class KwaiVideoAd
|
||||
{
|
||||
private KwaiAds.Scripts.Api.Reward.IRewardAdController _kwaiReward;
|
||||
private string _unitId;
|
||||
private IKwaiAdListener _kwaiAdListener;
|
||||
|
||||
public IKwaiAdListener KwaiAdListener => _kwaiAdListener;
|
||||
|
||||
public KwaiVideoAd(string unitId, IKwaiAdListener adListener)
|
||||
{
|
||||
_unitId = unitId;
|
||||
_kwaiAdListener = adListener;
|
||||
}
|
||||
|
||||
public void Load(string ecpmPrice = "0.01")
|
||||
{
|
||||
if(_kwaiReward != null)
|
||||
{
|
||||
_kwaiReward.Destroy();
|
||||
_kwaiReward = null;
|
||||
}
|
||||
|
||||
_kwaiReward = KwaiAds.Scripts.Api.KwaiAdsSdk.SDK.getRewardAdController();
|
||||
|
||||
// 构建KwaiRewardAdRequest
|
||||
KwaiRewardAdRequest kwaiRewardAdRequest = new KwaiRewardAdRequest(_unitId);
|
||||
// 选填, 可以设置低价 单位是$(美元,ecpm)
|
||||
kwaiRewardAdRequest.ExtParams[Constants.Request.BID_FLOOR_PRICE] = ecpmPrice;
|
||||
// 加载过程接受三个参数,
|
||||
// - KwaiRewardAdRequest 配置请求参数
|
||||
// - IRewardAdListener实现类,回调为激励
|
||||
_kwaiReward.Load(kwaiRewardAdRequest, new RewardAdListener(this), new RewardAdLoadListener(this));
|
||||
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
if(IsReady())
|
||||
{
|
||||
_kwaiReward.Show();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsReady()
|
||||
{
|
||||
return _kwaiReward != null && _kwaiReward.IsReady();
|
||||
}
|
||||
|
||||
public void NotifyWin(string minWinPrice)
|
||||
{
|
||||
//_kwaiReward?.NotifyWin(); //报错暂时屏蔽
|
||||
_kwaiReward?.NotifyWin(minWinPrice);
|
||||
}
|
||||
|
||||
public void NotifyLoss(string winPrice)
|
||||
{
|
||||
//_kwaiReward?.NotifyLoss();
|
||||
_kwaiReward?.NotifyLoss(winPrice);
|
||||
}
|
||||
|
||||
|
||||
private class RewardAdListener : IRewardAdListener
|
||||
{
|
||||
private KwaiVideoAd _kwaiVideoAd;
|
||||
|
||||
public RewardAdListener(KwaiVideoAd videoAd)
|
||||
{
|
||||
_kwaiVideoAd = videoAd;
|
||||
}
|
||||
|
||||
public void OnAdClick()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClick");
|
||||
_kwaiVideoAd.KwaiAdListener.OnClick();
|
||||
}
|
||||
|
||||
public void OnAdClose()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdClose");
|
||||
_kwaiVideoAd.KwaiAdListener.OnClosed();
|
||||
}
|
||||
|
||||
public void OnAdPlayComplete()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdPlayComplete");
|
||||
}
|
||||
|
||||
public void OnAdShow()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShow");
|
||||
_kwaiVideoAd.KwaiAdListener.OnShow();
|
||||
}
|
||||
|
||||
public void OnAdShowFailed(int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdShowFailed, code = {code}, msg = {msg}");
|
||||
_kwaiVideoAd.KwaiAdListener.OnShowFailed(code, msg);
|
||||
}
|
||||
|
||||
public void OnRewardEarned()
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnRewardEarned");
|
||||
_kwaiVideoAd.KwaiAdListener.OnReward();
|
||||
}
|
||||
}
|
||||
|
||||
private class RewardAdLoadListener : IRewardAdLoadListener
|
||||
{
|
||||
private KwaiVideoAd _kwaiVideoAd;
|
||||
|
||||
public RewardAdLoadListener(KwaiVideoAd videoAd)
|
||||
{
|
||||
_kwaiVideoAd = videoAd;
|
||||
}
|
||||
|
||||
public void OnAdLoadFailed(string trackId, int code, string msg)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadFailed, trackId = {trackId}, code = {code}, msg = {msg}");
|
||||
_kwaiVideoAd.KwaiAdListener.OnLoadFailed(trackId, code, msg);
|
||||
}
|
||||
|
||||
public void OnAdLoadStart(string trackId)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadStart, trackId = {trackId}");
|
||||
}
|
||||
|
||||
public void OnAdLoadSuccess(string trackId, string price)
|
||||
{
|
||||
KwaiLog.Log($"#Kwai OnAdLoadSuccess, trackId = {trackId}, price = {price}");
|
||||
_kwaiVideoAd.KwaiAdListener.OnLoaded(trackId, price);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
Regular → Executable
+2
-2
@@ -113,7 +113,7 @@ namespace KwaiAds.Scripts.Platforms.Android
|
||||
public void NotifyLoss(string winPrice)
|
||||
{
|
||||
if (_KwaiInterstitialAd != null)
|
||||
{
|
||||
{
|
||||
//_KwaiInterstitialAd.Call("getBidController", "sendBidLose");
|
||||
AndroidJavaObject bidController = _KwaiInterstitialAd.Call<AndroidJavaObject>("getBidController");
|
||||
bidController?.Call("sendBidLose", "101", winPrice);
|
||||
@@ -123,7 +123,7 @@ namespace KwaiAds.Scripts.Platforms.Android
|
||||
public void NotifyWin(string minWinPrice)
|
||||
{
|
||||
if (_KwaiInterstitialAd != null)
|
||||
{
|
||||
{
|
||||
//_KwaiInterstitialAd.Call("getBidController", "sendBidWin");
|
||||
AndroidJavaObject bidController = _KwaiInterstitialAd.Call<AndroidJavaObject>("getBidController");
|
||||
bidController?.Call("sendBidWin", minWinPrice);
|
||||
|
||||
Vendored
Regular → Executable
Vendored
Regular → Executable
+2
-2
@@ -113,7 +113,7 @@ namespace KwaiAds.Scripts.Platforms.Android
|
||||
public void NotifyLoss(string winPrice)
|
||||
{
|
||||
if (_KwaiRewardAd != null)
|
||||
{
|
||||
{
|
||||
//_KwaiRewardAd.Call("getBidController", "sendBidLose");
|
||||
AndroidJavaObject bidController = _KwaiRewardAd.Call<AndroidJavaObject>("getBidController");
|
||||
bidController?.Call("sendBidLose", "101", winPrice);
|
||||
@@ -123,7 +123,7 @@ namespace KwaiAds.Scripts.Platforms.Android
|
||||
public void NotifyWin(string minWinPrice)
|
||||
{
|
||||
if (_KwaiRewardAd != null)
|
||||
{
|
||||
{
|
||||
//_KwaiRewardAd.Call("getBidController", "sendBidWin");
|
||||
AndroidJavaObject bidController = _KwaiRewardAd.Call<AndroidJavaObject>("getBidController");
|
||||
bidController?.Call("sendBidWin", minWinPrice);
|
||||
|
||||
Vendored
Regular → Executable
Reference in New Issue
Block a user