侧边栏壁纸
博主头像
Gstory's Blog 博主等级

每天进步一点点!

  • 累计撰写 108 篇文章
  • 累计创建 23 个标签
  • 累计收到 11 条评论

目 录CONTENT

文章目录

Flutter字节跳动穿山甲广告、腾讯优量汇(广点通)聚合广告插件

gstory
2021-06-02 / 0 评论 / 0 点赞 / 194 阅读 / 0 字 / 正在检测是否收录...
温馨提示:
本文最后更新于2023-10-08,若内容或图片失效,请留言反馈。 部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

flutter_universalad是一款聚合字节跳动穿山甲flutter_unionad、腾讯优量汇(广点通)flutter_tencentad的聚合广告插件,方便直接调用多个厂商广告。体验demo

文档

推荐参考以下插件的文档进行插件的集成。

本地环境

[✓] Flutter (Channel stable, 2.5.0, on macOS 11.6 20G165 darwin-x64, locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.60.1)
[✓] Connected device (4 available)

集成步骤

1、pubspec.yaml

flutter_universalad: ^1.0.4

2、引入

import 'package:flutter_universalad/flutter_universalad.dart';

使用

1、SDK初始化

await FlutterUniversalad.register(
        pAndroidId: "5098580",
        //穿山甲android id
        pIosId: "5098580",
        //穿山甲ios id
        tAndroidId: "1200009850",
        //优量汇android id
        tIosId: "1200082163",
        //优量汇ios id
        appName: "Flutter_universalad",
        //app名字
        debug: true,
        //是否显示日志
      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(
        //穿山甲广告android id
        pAndroidId: "945418088",
        //穿山甲广告ios id
        pIosId: "945418088",
        //优量汇广告android id
        tAndroidId: "5042816813706194",
        //优量汇广告ios id
        tIosId: "8062535056034159",
        //奖励名称
        rewardName: "金币",
        //奖励数量
        rewardAmount: 10,
        //用户id
        userID: "123",
        //交替加载
        loadType: UniversalLoadType.INTURN,
        //穿山甲出现的几率
        probability: 0.5,
        //扩展参数,开启服务器验证时上报
        customData: "",
    );

激励广告监听

FlutterUniversalAdStream.initAdStream(
    uRewardCallBack: URewardCallBack(
    onShow: (sdkType) {
        print("$sdkType  激励广告开始显示");
        },
    onFail: (sdkType, code, message) {
        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(
        "$sdkType  激励广告观看成功 transId=$transId verify=$verify amount=$amount name=$name");
        },
    ),  
   );

展示激励广告

FlutterUniversalad.showRewardVideoAd();

4、插屏广告

预加载插屏广告

await FlutterUniversalad.loadInterstitialAd(
    //穿山甲广告android id
    pAndroidId: "946201351",
    //穿山甲广告ios id
    pIosId: "946201351",
    //优量汇广告android id
    tAndroidId: "9062813863614416",
    //优量汇广告ios id
    tIosId: "1052938046031440",
    //是否全屏 仅优量汇起效
    isFullScreen: false,
    //交替加载
    loadType: UniversalLoadType.INTURN,
    //穿山甲出现的几率
    probability: 0.5,
);

插屏广告监听

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(
        //穿山甲广告android id
        pAndroidId: "887367774",
        //穿山甲广告ios id
        pIosId: "887367774",
        //优量汇广告android id
        tAndroidId: "4052216802299999",
        //优量汇广告ios id
        tIosId: "8012030096434021",
        //广告加载模式 UniversalLoadType.INTURN 交替拉取广告,UniversalLoadType.RANDOWM 完全随机拉去广告
        loadType: UniversalLoadType.INTURN,
        //穿山甲出现的几率,UniversalLoadType.RANDOWM 起效,「0-1取值,0为不出现 1必出现」
        probability: 0.5,
        callBack: USplashCallBack(
          onShow: (sdkType) {
            print("$sdkType  开屏广告显示");
          },
          onFail: (sdkType, code, message) {
            print("$sdkType  开屏广告失败  $code $message");
            Navigator.pop(context);
          },
          onClick: (sdkType) {
            print("$sdkType  开屏广告点击");
          },
          onClose: (sdkType) {
            print("$sdkType  开屏广告关闭");
            Navigator.pop(context);
          },
        )

6、信息流广告

FlutterUniversalad.nativeAdView(
                //穿山甲广告android id
                pAndroidId: "945417699",
                //穿山甲广告ios id
                pIosId: "945417699",
                //优量汇广告android id
                tAndroidId: "4072918853903023",
                //优量汇广告ios id
                tIosId: "7082132016439065",
                width: 400.0,
                height: 260.0,
                //广告加载模式 UniversalLoadType.INTURN 交替拉取广告,UniversalLoadType.RANDOWM 完全随机拉去广告
                loadType: UniversalLoadType.INTURN,
                //穿山甲出现的几率,UniversalLoadType.RANDOWM 起效,「0-1取值,0为不出现 1必出现」
                probability: 0.5,
              callBack: UNativeCallBack(
                onShow: (sdkType) {
                  print("$sdkType  Native广告显示");
                },
                onFail: (sdkType, code, message) {
                  print("$sdkType  Native广告失败  $code $message");
                },
                onClick: (sdkType) {
                  print("$sdkType  Native广告点击");
                },
                onClose: (sdkType) {
                  print("$sdkType  Native广告关闭");
                },
              ),
            )

7、Banner广告

FlutterUniversalad.bannerAdView(
                //穿山甲广告android id
                pAndroidId: "945410197",
                //穿山甲广告ios id
                pIosId: "945410197",
                //优量汇广告android id
                tAndroidId: "8042711873318113",
                //优量汇广告ios id
                tIosId: "6062430096832369",
                width: 300.0,
                height: 100.0,
                //广告加载模式 UniversalLoadType.INTURN 交替拉取广告,UniversalLoadType.RANDOWM 完全随机拉去广告
                loadType: UniversalLoadType.INTURN,
                //穿山甲出现的几率,UniversalLoadType.RANDOWM 起效,「0-1取值,0为不出现 1必出现」
                probability: 0.5,
              callBack: UBannerCallBack(
                onShow: (sdkType) {
                  print("$sdkType  Banner广告显示");
                },
                onFail: (sdkType, code, message) {
                  print("$sdkType  Banner广告失败  $code $message");
                },
                onClick: (sdkType) {
                  print("$sdkType  Banner广告点击");
                },
                onClose: (sdkType) {
                  print("$sdkType  Banner广告关闭");
                },
              ),
            )

说明

  • 聚合插件仅支持穿山甲、优量汇(广点通)的andorid、ios广告。

插件链接

插件地址
字节穿山甲广告插件flutter_unionad
腾讯优量汇广告插件flutter_tencentad
聚合广告插件flutter_universalad
百度百青藤广告插件flutter_baiduad
字节穿山甲内容合作插件flutter_pangrowth
文档预览插件file_preview
滤镜gpu_image
0

评论区