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

每天进步一点点!

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

目 录CONTENT

文章目录

Flutter信天翁广告插件

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

Flutter快速接入信天翁广告

官方文档

集成步骤

1、pubspec.yaml

由于ios sdk只能本地引入且大小已超过插件上传100M的限制,所以只能通过git引入插件使用

//quakerbirdad: ^0.0.6 
quakerbirdad:
    git:
      url: https://github.com/gstory0404/quakerbirdad.git
      ref: 0.0.7

引入

import 'package:quakerbirdad/quakerbirdad.dart';

2、Android

根据官方文件进行权限等配置。

3、IOS

根据官方文件进行权限等配置。

注意事项

  • 广告view传入的宽高仅加载时起效,加载完成后动态修改成SDK返回广告大小

使用

SDK初始化

QuakerBirdAd.register(
      //android  app id
      androidAppId: "881",
      //ios app id
      iosAppId: "881",
      //是否显示日志,建议正式上线时,设置为false
      debug: true,
      //是否非WiFi下提示确认
      download: QuakerBirdAdDownload.ALWAYS,
      //应用渠道id (非必填,填写后可以按渠道查看广告数据)
      channelId: "test",
      //设置是否初始化时就申请权限
      permission: true,
    );

获取SDK版本

await QuakerBirdAd.getSDKVersion();

获取权限

目前仅iOS生效,用于ATT权限获取

QuakerBirdAd.requestPermission().then((value) => {
   print("获取权限结果 $value")
});

开屏广告

QuakerBirdAdSplash(
      androidId: "3561",
      iosId: "3561",
      width: window.physicalSize.width / window.devicePixelRatio,
      height: window.physicalSize.height / window.devicePixelRatio,
      callBack: QuakerBirdAdSplashCallBack(
        onShow: () {
          print("插屏广告显示");
        },
        onError: (msg) {
          print("插屏广告失败 $msg");
        },
        onClick: () {
          print("插屏广告点击");
        },
        onDismiss: () {
          print("插屏广告关闭");
        },
        onStatus: (type, platform, status, msg) {
          print("插屏广告状态 类型:$type  平台:$platform  状态:$status  错误消息 (失败时有效):$msg");
        },
      ),
    );

横幅广告

QuakerBirdAdBanner(
              androidId: "1983",
              iosId: "1983", 
              width: 500,
              height: 50,
              callBack: QuakerBirdAdBannerCallBack(
                  onShow: (){
                    print("横幅广告显示");
                  },
                  onError: (msg){
                    print("横幅广告失败 $msg");
                  },
                  onClick: (){
                    print("横幅广告点击");
                  },
                  onDismiss: (){
                    print("横幅广告关闭");
                    Navigator.pop(context);
                  },
                  onStatus: (type,platform,status,msg){
                    print("横幅广告状态 类型:$type  平台:$platform  状态:$status  错误消息 (失败时有效):$msg");
                  }
              ),
            );

信息流广告

QuakerBirdAdNative(
              androidId: "2351",
              iosId: "2351",
              width: 500,
              height: 200,
              callBack: QuakerBirdAdNativeCallBack(
                  onShow: (){
                    print("信息流广告显示");
                  },
                  onError: (msg){
                    print("信息流广告失败 $msg");
                  },
                  onClick: (){
                    print("信息流广告点击");
                  },
                  onDismiss: (){
                    print("信息流广告关闭");
                    Navigator.pop(context);
                  },
                  onStatus: (type,platform,status,msg){
                    print("信息流广告状态 类型:$type  平台:$platform  状态:$status  错误消息 (失败时有效):$msg");
                  }
              ),
            ),

模版广告

QuakerBirdAdExpress(
              androidId: "8461",
              iosId: "8461",
              width: 500,
              height: 300,
              callBack: QuakerBirdAdExpressCallBack(
                  onShow: (){
                    print("模版广告显示");
                  },
                  onError: (msg){
                    print("模版广告失败 $msg");
                  },
                  onClick: (){
                    print("模版广告点击");
                  },
                  onDismiss: (){
                    print("模版广告关闭");
                    Navigator.pop(context);
                  },
                  onStatus: (type,platform,status,msg){
                    print("模版广告状态 类型:$type  平台:$platform  状态:$status  错误消息 (失败时有效):$msg");
                  }
              ),
            ),

模版视频广告

QuakerBirdAdExpressDraw(
              androidId: "8517",
              iosId: "8517",
              width: 500,
              height: 300,
              callBack: QuakerBirdAdExpressDrawCallBack(
                  onShow: (){
                    print("模版视频广告显示");
                  },
                  onError: (msg){
                    print("模版视频广告失败 $msg");
                  },
                  onClick: (){
                    print("模版视频广告点击");
                  },
                  onDismiss: (){
                    print("模版视频广告关闭");
                    Navigator.pop(context);
                  },
                  onStatus: (type,platform,status,msg){
                    print("模版视频广告状态 类型:$type  平台:$platform  状态:$status  错误消息 (失败时有效):$msg");
                  }
              ),
            ),

插屏广告

请求广告

QuakerBirdAd.loadInteractionAd(androidId: "11087", iosId: "11087");

监听结果

FlutterUnionadStream.initAdStream(
    rewardCallBack: QuakerBirdAdRewardCallBack(
        onShow: () {
          print("激励广告显示");
        },
        onError: (msg) {
          print("激励广告失败 $msg");
        },
        onClick: () {
          print("激励广告点击");
        },
        onDismiss: () {
          print("激励广告关闭");
        },
        onStatus: (type, platform, status, msg) {
          print("激励广告状态 类型:$type  平台:$platform  状态:$status  错误消息 (失败时有效):$msg");
        },
        onReward: (type) {
          print("激励广告奖励 $type");
        },
    ),
);

全屏广告

请求广告

 QuakerBirdAd.loadFullScreenAd(androidId: "8811", iosId: "8811");

监听结果

FlutterUnionadStream.initAdStream(
    fullScreenCallBack: QuakerBirdAdFullScreenCallBack(
        onShow: () {
          print("全屏广告显示");
        },
        onError: (msg) {
          print("全屏广告失败 $msg");
        },
        onClick: () {
          print("全屏广告点击");
        },
        onDismiss: () {
          print("全屏广告关闭");
        },
        onStatus: (type, platform, status, msg) {
          print("全屏广告状态 类型:$type  平台:$platform  状态:$status  错误消息 (失败时有效):$msg");
        },
    ),
);

激励广告

请求广告

 QuakerBirdAd.loadRewardVideoAd(androidId: "1028", iosId: "1028");

监听结果

FlutterUnionadStream.initAdStream(
    rewardCallBack: QuakerBirdAdRewardCallBack(
        onShow: () {
          print("激励广告显示");
        },
        onError: (msg) {
          print("激励广告失败 $msg");
        },
        onClick: () {
          print("激励广告点击");
        },
        onDismiss: () {
          print("激励广告关闭");
        },
        onStatus: (type, platform, status, msg) {
          print("激励广告状态 类型:$type  平台:$platform  状态:$status  错误消息 (失败时有效):$msg");
        },
        onReward: (type) {
          print("激励广告奖励 $type");
        },
    ),
);
0

评论区