flutter_tencentad是一款集成了腾讯优量汇广告Android和iOSSDK的Flutter插件,方便直接调用优量汇广告SDK方法快速开发,插件仓库
由于优量汇需要上架应用才能使用广告,所以demo不能直接运行,体验demo
flutter_tencentad: ^0.0.2
引入
import 'package:flutter_tencentad/flutter_tencentad.dart';
SDK(4.380.1250)已配置插件中无需额外配置,只需要在android目录中AndroidManifest.xml配置
开发中
await FlutterTencentad.register(
appId: "1200009850", //appid
debug: true, //是否显示日志log
);
await FlutterTencentad.getSDKVersion();
FlutterTencentad.splashAdView(
//广告id
codeId: "4052216802299999",
设置开屏广告从请求到展示所花的最大时长(并不是指广告曝光时长),取值范围为[1500, 5000]ms
fetchDelay: 3000,
//广告回调
callBack: SplashAdCallBack(
onShow: () {
print("开屏广告显示");
},
onADTick: (time) {
print("开屏广告倒计时剩余时间 $time");
},
onClick: () {
print("开屏广告点击");
},
onClose: () {
print("开屏广告关闭");
Navigator.pop(context);
},
onExpose: () {
print("开屏广告曝光");
},
onFail: (code, message) {
print("开屏广告失败 $code $message");
},
),
),
FlutterTencentad.bannerAdView(
//广告id
codeId: "8042711873318113",
//广告宽 单位dp
viewWidth: 500,
//广告高 单位dp 宽高比应该为6.4:1
viewHeight: 100,
// 广告回调
callBack: BannerAdCallBack(
onShow: () {
print("Banner广告显示");
},
onFail: (code, message) {
print("Banner广告错误 $code $message");
},
onClose: () {
print("Banner广告关闭");
},
onExpose: () {
print("Banner广告曝光");
},
onClick: () {
print("Banner广告点击");
},
),
),
FlutterTencentad.expressAdView(
//广告id
codeId: "4072918853903023",
//广告宽 单位dp
viewWidth: 400,
//广告高 单位dp
viewHeight: 300,
//回调事件
callBack: ExpressAdCallBack(
onShow: () {
print("动态信息流广告显示");
},
onFail: (code, message) {
print("动态信息流广告错误 $code $message");
},
onClose: () {
print("动态信息流广告关闭");
},
onExpose: () {
print("动态信息流广告曝光");
},
onClick: () {
print("动态信息流广告点击");
},
)
),
预加载激励视频广告
await FlutterTencentad.loadRewardVideoAd(
//广告id
codeId: "5042816813706194",
);
显示激励视频广告
await FlutterTencentad.showRewardVideoAd();
监听激励视频结果
FlutterTencentAdStream.initAdStream(
//激励广告
rewardAdCallBack: RewardAdCallBack(
onShow: () {
print("激励广告显示");
},
onClick: () {
print("激励广告点击");
},
onFail: (code, message) {
print("激励广告失败 $code $message");
},
onClose: () {
print("激励广告关闭");
},
onReady: () async {
print("激励广告预加载准备就绪");
await FlutterTencentad.showRewardVideoAd();
},
onUnReady: () {
print("激励广告预加载未准备就绪");
},
onVerify: (transId) {
print("激励广告奖励 $transId");
},
),
);
预加载插屏广告
await FlutterTencentad.loadUnifiedInterstitialAD(
//广告id
codeId: "9062813863614416",
//是否全屏
isFullScreen: false,
);
显示插屏广告
await FlutterTencentad.showUnifiedInterstitialAD();
插屏广告结果监听
FlutterTencentAdStream.initAdStream(
interactionAdCallBack: InteractionAdCallBack(
onShow: () {
print("插屏广告显示");
},
onClick: () {
print("插屏广告点击");
},
onFail: (code, message) {
print("插屏广告失败 $code $message");
},
onClose: () {
print("插屏广告关闭");
},
onReady: () async {
print("插屏广告预加载准备就绪");
await FlutterTencentad.showUnifiedInterstitialAD();
},
onUnReady: () {
print("插屏广告预加载未准备就绪");
},
),
);