Skip to main content

插屏广告

1、请求广告#

using TradplusSDK.Api;
//流量分组
Dictionary<string, string> customMap = {};
//local自定义Map,仅Android支持
Dictionary<string, string> localParams = {};
//设置附加参数 extra
TPInterstitialExtra extra = new TPInterstitialExtra();
extra.customMap = customMap;
extra.localParams = localParams;
//请求广告
TradplusInterstitial.Instance().LoadInterstitialAd("unitId", extra);

参数说明

unitId:TradPlus后台创建的广告位ID#
  • 开发者需正确填入,例如:unitId设置前后有空格,均会导致广告因拉不到配置而请求失败。
TPInterstitialExtra:额外参数#
  • customMap:设置流量分组 相关属性参数
  • localParams:设置本地参数。仅Android支持。个别广告平台特殊需要设定的参数。

2、检查是否有可用广告#

  • 建议开发者展示广告前,调用该API判断是否有可用广告,有广告再调用show方法
  • true表示有可用广告,false表示暂时无可用广告
bool isReady = TradplusInterstitial.Instance().InterstitialAdReady("unitId");

3、进入广告场景#

TradplusInterstitial.Instance().EntryInterstitialAdScenario("unitId", "sceneId");

参数说明

sceneId :广告场景ID (推荐)#
  • 开发者可在在TradPlus后台创建,位置如下:应用管理--广告场景。
  • 具体如何调用,可以参考广告场景的调用时机和用途说明
  • 进入广告场景时传入sceneId,展示广告时也需传入sceneId,否则会影响统计。

4、展示广告#

//调用展示前先判断是否有广告
bool isReady = TradplusInterstitial.Instance().InterstitialAdReady("unitId");
if(isReady)
{
//展示广告
TradplusInterstitial.Instance().ShowInterstitialAd("unitId", "sceneId");
}

5、监听回调#

参数说明

常用回调#

// 广告加载成功
TradplusInterstitial.Instance().OnInterstitialLoaded += OnlLoaded;
// 广告加载失败
TradplusInterstitial.Instance().OnInterstitialLoadFailed += OnLoadFailed;
// 广告展示成功
TradplusInterstitial.Instance().OnInterstitialImpression += OnImpression;
// 广告展示失败
TradplusInterstitial.Instance().OnInterstitialShowFailed += OnShowFailed;
// 广告点击
TradplusInterstitial.Instance().OnInterstitialClicked += OnClicked;
// 广告关闭
TradplusInterstitial.Instance().OnInterstitialClosed += OnClosed;
// 每层waterfall加载失败时回调
TradplusInterstitial.Instance().OnInterstitialOneLayerLoadFailed += OnOneLayerLoadFailed;
void OnlLoaded(string adunit, Dictionary<string, object> adInfo)
{
// 广告加载成功
}
void OnLoadFailed(string adunit, Dictionary<string, object> error)
{
// 广告加载失败
}
void OnImpression(string adunit, Dictionary<string, object> adInfo)
{
// 广告展示成功
}
void OnShowFailed(string adunit, Dictionary<string, object> adInfo, Dictionary<string, object> error)
{
// 广告展示失败
}
void OnClicked(string adunit, Dictionary<string, object> adInfo)
{
// 广告点击
}
void OnClosed(string adunit, Dictionary<string, object> adInfo)
{
// 广告关闭
}
void OnOneLayerLoadFailed(string adunit, Dictionary<string, object> adInfo, Dictionary<string, object> error)
{
// 每层waterfall加载失败时回调
}

广告源维度回调监听(可选)#

//每次调用load方法时返回的回调
TradplusInterstitial.Instance().OnInterstitialStartLoad += OnStartLoad;
//Bidding开始(每有一个bidding广告源回调一次)
TradplusInterstitial.Instance().OnInterstitialBiddingStart += OnBiddingStart;
//Bidding加载结束(每有一个bidding广告源回调一次)
TradplusInterstitial.Instance().OnInterstitialBiddingEnd += OnBiddingEnd;
//每层waterfall开始加载时回调
TradplusInterstitial.Instance().OnInterstitialOneLayerStartLoad += OnOneLayerStartLoad;
//每层waterfall加载成功时回调
TradplusInterstitial.Instance().OnInterstitialOneLayerLoaded += OnOneLayerLoaded;
//视频播放开始
TradplusInterstitial.Instance().OnInterstitialVideoPlayStart += OnVideoPlayStart;
//视频播放结束
TradplusInterstitial.Instance().OnInterstitialVideoPlayEnd += OnVideoPlayEnd;
//加载流程结束
TradplusInterstitial.Instance().OnInterstitialAllLoaded += OnAllLoaded;
//调用load之后如果收到此回调,说明广告位仍处于加载状态,无法触发新的一轮广告加载。V1.0.5 新增回调
TradplusInterstitial.Instance().OnInterstitialIsLoading += OnAdIsLoading;
void OnStartLoad(string adunit, Dictionary<string, object> adInfo)
{
//每次调用load方法时返回的回调
}
void OnBiddingStart(string adunit, Dictionary<string, object> adInfo)
{
//Bidding开始(每有一个bidding广告源回调一次)
}
void OnBiddingEnd(string adunit, Dictionary<string, object> adInfo, Dictionary<string, object> error)
{
//Bidding加载结束(每有一个bidding广告源回调一次)
}
void onAdIsLoading(string unitId)
{
//调用load之后如果收到此回调,说明广告位仍处于加载状态,无法触发新的一轮广告加载。V1.0.5 新增回调
}
void OnOneLayerStartLoad(string adunit, Dictionary<string, object> adInfo)
{
//每层waterfall开始加载时回调
}
void OnOneLayerLoaded(string adunit, Dictionary<string, object> adInfo)
{
//每层waterfall加载成功时回调
}
void OnVideoPlayStart(string adunit, Dictionary<string, object> adInfo)
{
//视频播放开始
}
void OnVideoPlayEnd(string adunit, Dictionary<string, object> adInfo)
{
//视频播放结束
}
void OnAllLoaded(string adunit, bool isSuccess)
{
//加载流程结束
// isSuccess 返回true,表示此次请求,有广告源加载成功
// isSuccess 返回false,表示此次请求,广告位adUnitId下所有广告源加载失败
}

下载监听 快手、穿山甲支持(可选)(仅Android支持)#

void OnDownloadStart(string adunit, Dictionary<string, object> adInfo, int totalBytes,int currBytes, string fileName,string appName )
{
// 开始下载回调
// totalBytes:文件总大小(单位:字节)
// currBytes:当前已下载的大小(单位:字节)
// fileName:文件名称
// appName:文件对应的应用名称
}
void OnDownloadUpdate(string adunit, Dictionary<string, object> adInfo, int totalBytes, int currBytes, string fileName, string appName,int progress)
{
// 下载进度更新回调
// progress:下载进度
}
void OnDownloadPause(string adunit, Dictionary<string, object> adInfo, int totalBytes, int currBytes, string fileName, string appName)
{
// 暂停下载回调
}
void OnDownloadFinish(string adunit, Dictionary<string, object> adInfo, int totalBytes, int currBytes, string fileName, string appName)
{
// 下载完成回调
}
void OnDownloadFailed(string adunit, Dictionary<string, object> adInfo, int totalBytes, int currBytes, string fileName, string appName)
{
// 下载失败回调
}
void OnInstallled(string adunit, Dictionary<string, object> adInfo, int totalBytes, int currBytes, string fileName, string appName)
{
// Apk安装完成回调
}