callBack: RegisterCallBack(pangolinInit: (result) {
setState(() {
_registerResult = “$_registerResult 穿山甲初始化 $result”;
});
}, tencentInit: (result) {
setState(() {
_registerResult = “$_registerResult 优量汇初始化 $result”;
_getVersion();
});
}),
);
2、获取SDK版本
VersionEntity versionEntity = await FlutterUniversalad.getSDKVersion();
_sdkVersion =
“穿山甲SDK ${versionEntity.pangolinVersion} 优量汇SDK ${versionEntity.tencentVersion}”;
3、激励广告
预加载激励广告
await FlutterUniversalad.loadRewardVideoAd(
pangolinId: “945418088”,//穿山甲广告id
tencentId: “5042816813706194”,//优量汇广告id
rewardName: “金币”,//奖励名称
rewardAmount: 10,//奖励数量
userID: “123”,//用户id
loadType: UniversalLoadType.INTURN,//广告加载模式 UniversalLoadType.INTURN 交替拉取广告,UniversalLoadType.RANDOWM 完全随机拉去广告
probability: 0.5);//穿山甲出现的几率,UniversalLoadType.RANDOWM 起效,「0-1取值,0为不出现 1必出现」
},
复制代码
激励广告监听
FlutterUniversalAdStream.initAdStream(
uRewardCallBack: URewardCallBack(
onShow: (sdkType) {
print("$sdkType 激励广告开始显示");
},
onFail: (sdkType, code, message) {
//只有两个插件都失败的情况下才会返回失败,只返回最后一次失败的参数,单独一个失败,会保底去拉取另一个sdk广告
print("$sdkType 激励广告失败 $code $message");
},
onClick: (sdkType) {
print("$sdkType 激励广告点击");
},
onClose: (sdkType) {
print("$sdkType 激励广告关闭");
},
onReady: (sdkType) {
print("$sdkType 激励广告预加载完成");
FlutterUniversalad.showRewardVideoAd();
},
onUnReady: (sdkType) {
print("$sdkType 激励广告未预加载");
},
onVerify: (sdkType, transId, verify, amount, name) {
print(“ s d k T y p e ! [ ] ( h t t p s : / / w w w . h u a l i g s . c n / i m a g e / 61 d b a 891 e d 8 e e . j p g ) 激 励 广 告 观 看 成 功 t r a n s I d = sdkType ![](https://www.hualigs.cn/image/61dba891ed8ee.jpg) 激励广告观看成功 transId= sdkType![](https://www.hualigs.cn/image/61dba891ed8ee.jpg)激励广告观看成功transId=transId verify= v e r i f y a m o u n t = verify amount= verifyamount=amount name=$name”);
},
),
);
展示激励广告
FlutterUniversalad.showRewardVideoAd();
4、插屏广告
预加载插屏广告
await FlutterUniversalad.loadInterstitialAd(
pangolinId: “946201351”,//穿山甲广告id
tencentId: “9062813863614416”,//优量汇广告id
isFullScreen: false,//是否全屏 仅优量汇起效
loadType: UniversalLoadType.INTURN,//广告加载模式 UniversalLoadType.INTURN 交替拉取广告,UniversalLoadType.RANDOWM 完全随机拉去广告
probability: 0.5);//穿山甲出现的几率,UniversalLoadType.RANDOWM 起效,「0-1取值,0为不出现 1必出现」
},
插屏广告监听
FlutterUniversalAdStream.initAdStream(
uInteractionCallBack: UInteractionCallBack(
onShow: (sdkType) {
print("$sdkType 插屏广告开始显示");
},
onFail: (sdkType, code, message) {
//只有两个插件都失败的情况下才会返回失败,只返回最后一次失败的参数,单独一个失败,会保底去拉取另一个sdk广告
print("$sdkType 插屏广告失败 $code $message");
},
onClick: (sdkType) {
print("$sdkType 插屏广告点击");
},
onClose: (sdkType) {
print("$sdkType 插屏广告关闭");
},
onReady: (sdkType) {
print("$sdkType 插屏广告预加载完成");
FlutterUniversalad.showInterstitialAd();
},
onUnReady: (sdkType) {
print("$sdkType 插屏广告未预加载");
},
),
);
展示插屏广告
FlutterUniversalad.showInterstitialAd();
5、开屏广告
FlutterUniversalad.splashAdView(
pangolinId: “887367774”,//穿山甲广告id
tencentId: “4052216802299999”,//优量汇广告id
loadType: UniversalLoadType.INTURN,//广告加载模式 UniversalLoadType.INTURN 交替拉取广告,UniversalLoadType.RANDOWM 完全随机拉去广告
probability: 0.5,//穿山甲出现的几率,UniversalLoadType.RANDOWM 起效,「0-1取值,0为不出现 1必出现」
callBack: USplashCallBack(
onShow: (sdkType) {
print("$sdkType 开屏广告显示");
},
onFail: (sdkType, code, message) {
print("$sdkType 开屏广告失败 $code $message");
Navigator.pop(context);
},