# 9. 插屏广告
# (1) API说明
ATInterstitialAd:
| API | 参数 | 说明 |
|---|---|---|
| loadInterstitialAd | string placementid,Dictionary<string,string> extra | 加载广告 |
| hasInterstitialAdReady | string placementid | 判断是否有广告缓存 |
| showInterstitialAd | string placementid,Dictionary<string,string> extra | 显示广告 |
# (2) 加载插屏广告
使用以下代码加载插屏广告:
public void loadInterstitialAd()
{
if(callback == null) {
callback = new InterstitalCallback();
ATInterstitialAd.Instance.setListener(callback);
}
Dictionary<string,string> jsonmap = new Dictionary<string,string>();
//Only for Sigmob
jsonmap.Add(AnyThinkAds.Api.ATConst.USE_REWARDED_VIDEO_AS_INTERSTITIAL, AnyThinkAds.Api.ATConst.USE_REWARDED_VIDEO_AS_INTERSTITIAL_NO);
//jsonmap.Add(AnyThinkAds.Api.ATConst.USE_REWARDED_VIDEO_AS_INTERSTITIAL, AnyThinkAds.Api.ATConst.USE_REWARDED_VIDEO_AS_INTERSTITIAL_YES);
ATInterstitialAd.Instance.loadInterstitialAd(mPlacementId_interstitial_all, jsonmap);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
注: 请参阅下文,了解如何获得有关插屏广告事件的通知(加载成功/失败,展示,点击,视频开始/结束)。
# (3) 展示插屏广告
与激励视频相同,插屏广告只要调用展示api并传递展示广告位ID作为参数:
public void showInterstitialAd()
{
ATInterstitialAd.Instance.showInterstitialAd(mPlacementId_interstitial_all);
}
1
2
3
4
2
3
4
当用到 场景 功能时:
public void showInterstitialAd()
{
Dictionary<string, string> jsonmap = new Dictionary<string, string>();
jsonmap.Add(AnyThinkAds.Api.ATConst.SCENARIO, showingScenarioID);
ATInterstitialAd.Instance.showInterstitialAd(mPlacementId_interstitial_all, jsonmap);
}
1
2
3
4
5
6
2
3
4
5
6
# (4) 实现插屏的监听器
您可以实现ATInterstitialAdListener接口的类,来获得有关插屏广告事件的通知:
class InterstitalCallback : ATInterstitialAdListener
{
public void onInterstitialAdClick(string unitId, ATCallbackInfo callbackInfo)
{
Debug.Log("Developer callback onInterstitialAdClick :" + unitId);
}
public void onInterstitialAdClose(string unitId, ATCallbackInfo callbackInfo)
{
Debug.Log("Developer callback onInterstitialAdClose :" + unitId);
}
public void onInterstitialAdEndPlayingVideo(string unitId, ATCallbackInfo callbackInfo)
{
Debug.Log("Developer callback onInterstitialAdEndPlayingVideo :" + unitId);
}
public void onInterstitialAdFailedToPlayVideo(string unitId, string code, string message)
{
Debug.Log("Developer callback onInterstitialAdFailedToPlayVideo :" + unitId + "--code:" + code + "--msg:" + message);
}
public void onInterstitialAdLoad(string unitId)
{
Debug.Log("Developer callback onInterstitialAdLoad :" + unitId);
}
public void onInterstitialAdLoadFail(string unitId, string code, string message)
{
Debug.Log("Developer callback onInterstitialAdLoadFail :" + unitId + "--code:" + code + "--msg:" + message);
}
public void onInterstitialAdShow(string unitId, ATCallbackInfo callbackInfo)
{
Debug.Log("Developer callback onInterstitialAdShow :" + unitId);
}
public void onInterstitialAdStartPlayingVideo(string unitId, ATCallbackInfo callbackInfo)
{
Debug.Log("Developer callback onInterstitialAdStartPlayingVideo :" + unitId);
}
public void onInterstitialAdFailedToShow(string unitId)
{
Debug.Log("Developer callback onInterstitialAdFailedToShow :" + unitId);
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48