开屏广告
1. 接口API说明
1.1 开屏请求类
AdRequest
| 参数 | 说明 |
|---|---|
| placementId | 广告位 |
| userId | 媒体用户体系ID ,可选 ,默认null |
| options | 扩展参数,默认null |
1.2 开屏对象类
** WindmillSplashAd**
| 方法 | 说明 |
|---|---|
| WindmillSplashAd(required AdRequest this.request, required this.width, required this.height, this.title, this.desc, required WindmillSplashListener<WindmillSplashAd> this.listener ) | 初始化开屏广告对象, request 为广告请求对象,必传, width广告宽 必传, height 广告位高 必传, title 可选, desc 品牌区应用描述 可选, listener 开屏视频接口 必传 |
| loadAd() | 发起广告加载 |
| isReady() | 判断当前广告是否存在可展示的广告 |
| showAd() | 展示广告 |
| getAdInfo() | 获取广告信息 |
| getCacheAdInfoList() | 查询当前广告位的所有缓存信息的AdInfo对象、在广告加载成功后调用 |
| destroy() | 销毁广告 |
1.4 开屏回调说明
WindmillSplashListener 开屏回调说明
| 回调方法 | 说明 |
|---|---|
| onAdFailedToLoad (WindmillSplashAd ad, WMError error) | 广告加载失败 |
| onAdLoaded (WindmillSplashAd ad) | 广告加载成功 |
| onAdOpened (WindmillSplashAd ad) | 广告开始展示 |
| onAdShowError (WindmillSplashAd ad, WMError error) | 广告开始展示失败 |
| onAdClicked (WindmillSplashAd ad) | 广告被用户点击 |
| onAdSkiped (WindmillSplashAd ad) | 用户跳过广告播放 |
| onAdClosed (WindmillSplashAd ad) | 广告关闭 |
| onAdDidCloseOtherController(WindmillSplashAd ad, WindmillInteractionType interactionType) | 此回调在广告跳转到其他控制器时,该控制器被关闭时调用interactionType:此参数可区分是打开的appstore/网页/视频广告详情页面 |
| onAdAutoLoadSuccess(WindmillSplashAd ad) | 广告播放中加载成功回调 |
| onAdAutoLoadFailed(WindmillSplashAd ad, WMError error) | 广告播放中加载失败回调 |
| onBidAdSourceStart(WindmillSplashAd ad, AdInfo? adInfo) | 竞价广告源开始竞价回调 |
| onBidAdSourceSuccess(WindmillSplashAd ad, AdInfo? adInfo) | 竞价广告源竞价成功回调 |
| onBidAdSourceFailed(WindmillSplashAd ad, AdInfo? adInfo, WMError error) | |
| onAdSourceStartLoading(WindmillSplashAd ad, AdInfo? adInfo) | 广告源开始加载回调 |
| onAdSourceSuccess(WindmillSplashAd ad, AdInfo? adInfo) | 广告源广告填充回调 |
| onAdSourceFailed(WindmillSplashAd ad, AdInfo? adInfo, WMError error) | 广告源加载失败回调 |
2. 示例代码
2.1 创建开屏广告对象
dart
AdRequest request = AdRequest(placementId: placementId);
Size size = Size(window.physicalSize.width, window.physicalSize.height);
if(Platform.isIOS){
size = Size(window.physicalSize.width/window.devicePixelRatio, window.physicalSize.height/window.devicePixelRatio);
}
WindmillSplashAd splashAd = WindmillSplashAd( request:request, width:size.width, height:size.heigth,listener: listener);2.1 设置监听回调
dart
class IWMSplashListener extends WindmillSplashListener<WindmillSplashAd> {
@override
void onAdClicked(WindmillSplashAd ad) {
print('flu-Splash --- onAdClicked');
}
@override
void onAdFailedToLoad(WindmillSplashAd ad, WMError error) {
print('flu-Splash --- onAdFailedToLoad -- ${error.toJson()}');
}
@override
void onAdLoaded(WindmillSplashAd ad) {
print('flu-Splash --- onAdLoaded');
}
@override
void onAdOpened(WindmillSplashAd ad) {
print('flu-Splash --- onAdOpened');
}
@override
void onAdShowError(WindmillSplashAd ad,WMError error) {
print('flu-Splash --- onAdShowError -- ${error.toJson()}');
}
@override
void onAdClosed(WindmillSplashAd ad) {
// TODO: implement onAdClosed
print('flu-Splash --- onAdClosed');
}
@override
void onAdSkiped(WindmillSplashAd ad) {
// TODO: implement onAdSkiped
print('flu-Splash --- onAdSkiped');
}
@override
void onAdDidCloseOtherController(WindmillSplashAd ad, WindmillInteractionType interactionType) {
print('flu-Splash --- onAdDidCloseOtherController -- ${interactionType.toString()}');
}
}
@override
void onAdSourceFailed(WindmillSplashAd ad, AdInfo? adInfo, WMError error) {
// TODO: implement onAdSourceFailed
print('onAdSourceFailed,adInfo:${adInfo?.toJson()}');
c.callbacks.add(
'onAdSourceFailed -- ${ad.request.placementId},adInfo:${adInfo?.toJson()},error: ${error.toJson()}');
}
@override
void onAdSourceStartLoading(WindmillSplashAd ad, AdInfo? adInfo) {
// TODO: implement onAdSourceStartLoading
print('onAdSourceStartLoading,adInfo:${adInfo?.toJson()}');
c.callbacks.add('onAdSourceStartLoading -- ${ad.request.placementId},adInfo:${adInfo?.toJson()}');
}
@override
void onAdSourceSuccess(WindmillSplashAd ad, AdInfo? adInfo) {
// TODO: implement onAdSourceSuccess
print('onAdSourceSuccess,adInfo:${adInfo?.toJson()}');
c.callbacks.add('onAdSourceSuccess -- ${ad.request.placementId},adInfo:${adInfo?.toJson()}');
}
@override
void onBidAdSourceFailed(WindmillSplashAd ad, AdInfo? adInfo, WMError error) {
// TODO: implement onBidAdSourceFailed
print('onBidAdSourceFailed,adInfo:${adInfo?.toJson()}');
c.callbacks.add(
'onBidAdSourceFailed -- ${ad.request.placementId},adInfo:${adInfo?.toJson()},error: ${error.toJson()}');
}
@override
void onBidAdSourceStart(WindmillSplashAd ad, AdInfo? adInfo) {
// TODO: implement onBidAdSourceStart
print('onBidAdSourceStart,adInfo:${adInfo?.toJson()}');
c.callbacks.add('onBidAdSourceStart -- ${ad.request.placementId},adInfo:${adInfo?.toJson()}');
}
@override
void onBidAdSourceSuccess(WindmillSplashAd ad, AdInfo? adInfo) {
// TODO: implement onBidAdSourceSuccess
print('onBidAdSourceSuccess,adInfo:${adInfo?.toJson()}');
c.callbacks.add('onBidAdSourceSuccess -- ${ad.request.placementId},adInfo:${adInfo?.toJson()}');
}
@override
void onAdAutoLoadFailed(WindmillSplashAd ad, WMError error) {
// TODO: implement onAdAutoLoadFailed
c.callbacks.add('onAdAutoLoadFailed -- ${ad.request.placementId}, error:${error.toJson()}');
}
@override
void onAdAutoLoadSuccess(WindmillSplashAd ad) {
// TODO: implement onAdAutoLoadSuccess
c.callbacks.add('onAdAutoLoadSuccess -- ${ad.request.placementId}');
}2.2 开屏广告加载
dart
splashAd.loadAd();2.3 开屏广告播放
dart
bool isReady = await splashAd.isReady();
if(isReady){
splashAd.showAd();
}