Giter Site home page Giter Site logo

ksad's Introduction

快手广告Flutter版本

官方文档

版本更新

更新日志

本地开发环境

[✓] Flutter (Channel stable, 3.16.0, on macOS 14.1.2 23B92 darwin-x64, locale
    zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] Android Studio (version 2023.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.3)
[✓] VS Code (version 1.85.0)
[✓] Connected device (4 available)
[✓] Network resources

集成步骤

1、pubspec.yaml

ksad: ^latest

引入

import 'package:ksad/ksad.dart';

注: 如果andorid出现NoClassDefFoundError闪退 java.lang.NoClassDefFoundError: Failed resolution of:Landroidx/localbroadcastmanager/content/LocalBroadcastManager 则在app下build.gradle中引入库 implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'

使用

1、SDK初始化

await KSAd.register(
      //androidId
      androidId: "1070600001",
      //iosId
      iosId: "1070600001",
      //是否显示日志log
      debug: true,
      //是否显示个性化推荐广告
      personalized: true,
    )

2、获取SDK版本

 await KSAd.getSDKVersion();

3、信息流广告(模版)

KSAdNativeWidget(
    //andorid广告位id
    androidId: "10706000004",
    //ios广告位id
    iosId: "10706000004",
    //广告宽
    viewWidth: 300,
    //广告高 加载成功后会自动修改为sdk返回广告高
    viewHeight: 200,
    //广告回调
    callBack: KSAdNativeCallBack(
    onShow: (){
      print("信息流广告显示");
    },
    onClose: (){
      print("信息流广告关闭");
    },
    onFail: (message){
      print("信息流广告出错 $message");
    },
    onClick: (){
      print("信息流广告点击");
    }
  ),
)

4、开屏广告

KSAdSplashWidget(
    androidId: "10511000010",
    iosId: "10511000009",
    callBack: KSAdSplashCallBack(
        onShow: (){
          print("开屏广告显示");
        },
        onClick: (){
          print("开屏广告点击");
        },
        onSkip: () {
          print("开屏广告跳过");
          Navigator.of(context).pop();
        },
        onClose: (){
          print("开屏广告关闭");
          Navigator.of(context).pop();
        },
        onFail: (msg){
          print("开屏广告错误  $msg");
          Navigator.of(context).pop();
        }
     ),
)

5、激励广告

预加载广告

await KSAd.loadRewardAd(
                  //android广告id
                  androidId: "10706000001",
                  //ios广告id
                  iosId: "10706000001",
                  //用户id
                  userID: "123",
                  //奖励
                  rewardName: "100金币",
                  //奖励数
                  rewardAmount: 100,
                  //json扩展参数 服务器回调使用
                  customData: "",
                );

显示广告

await KSAd.showRewardAd();

广告监听

KSAdStream.initAdStream(
      //激励广告
      rewardCallBack: KSAdRewardCallBack(
        onShow: () {
          print("激励广告显示");
        },
        onClick: () {
          print("激励广告点击");
        },
        onFail: (message) {
          print("激励广告失败 $message");
        },
        onClose: () {
          print("激励广告关闭");
        },
        onReady: () async {
          print("激励广告预加载准备就绪");
          await KSAd.showRewardAd();
        },
        onUnReady: () {
          print("激励广告预加载未准备就绪");
        },
        onVerify: (hasReward, rewardName, rewardAmount) {
          print("激励广告奖励  $hasReward   $rewardName   $rewardAmount");
        },
      ),
    );

6、插屏广告

预加载广告

await KSAd.loadInsertAd(
                  //android广告id
                  androidId: "10706000001",
                  //ios广告id
                  iosId: "10706000001",
                );

显示广告

await KSAd.showInsertAd();

广告监听

KSAdStream.initAdStream(
    //插屏广告
    insertCallBack: KSAdInsertCallBack(
        onShow: () {
          print("插屏广告显示");
        },
        onClick: () {
          print("插屏广告点击");
        },
        onFail: (message) {
          print("插屏广告失败 $message");
        },
        onClose: () {
          print("插屏广告关闭");
        },
        onReady: () async {
          print("插屏广告预加载准备就绪");
          await KSAd.showInsertAd();
        },
        onUnReady: () {
          print("插屏广告预加载未准备就绪");
        },
    )
)

插件链接

Flutter插件 地址
字节-穿山甲广告插件 flutter_unionad
腾讯-优量汇广告插件 flutter_tencentad
百度-百青藤广告插件 baiduad
字节-Gromore聚合广告 gromore
Sigmob广告 sigmobad
信天翁广告 quakerbirdad
快手广告 ksad
聚合广告插件(迁移至GTAds) flutter_universalad
GTAds聚合广告 GTAds
字节穿山甲内容合作插件 flutter_pangrowth
文档预览插件 file_preview
滤镜 gpu_image

开源不易,觉得有用的话可以请作者喝杯奶茶🧋

打赏

联系方式

ksad's People

Contributors

gstory0404 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

daguduiyuan

ksad's Issues

下次更新可以加一个 ecpm的值吗

image

override fun onRewardVerify() {
                Log.d(TAG, "激励视频广告验证22")
                var ecpm: String? = rewardVideoAd?.getECPM()?.toString() ?: "ECPM is null"
                KsadEvent.sendContent(mutableMapOf("adType" to "rewardAd", "onAdMethod" to "onVerify", "hasReward" to true, "rewardAmount" to rewardAmount, "rewardName" to rewardName,"ecpm" to ecpm))
            }

快手SDK升级

SDK能否抽个时间升级一下安卓跟iOS的SDK,iOS貌似有很多崩溃,开屏广告好像也加载不出来,不知道是不是SDK太老的原因。

显示“10002 找不到广告位”如何调试解决?

 //SDK初始化
            await KSAd.register(
              //androidId
              androidId: "1280600001",
              //iosId
              iosId: "1280600001",
              //是否显示日志log
              debug: true,
              //是否显示个性化推荐广告
              personalized: true,
            );
          await KSAd.loadInsertAd(
            androidId: "12806000004",
            //ios广告位id
            iosId: "12806000004",
          );
          //   await KSAd.showInsertAd();
          KSAdStream.initAdStream(
              //插屏广告
              insertCallBack: KSAdInsertCallBack(
            onShow: () {
              debugPrint("插屏广告显示");
            },
            onClick: () {
              debugPrint("插屏广告点击");
            },
            onFail: (message) {
              debugPrint("插屏广告失败 $message");
            },
            onClose: () {
              debugPrint("插屏广告关闭");
            },
            onReady: () async {
              debugPrint("插屏广告预加载准备就绪");
              await KSAd.showInsertAd();
            },
            onUnReady: () {
              debugPrint("插屏广告预加载未准备就绪");
            },
          ));

显示

W/KSAdSDK (21149): [KsAdInterstitialLoadManager]: loadInterstitialAd onError:code:10002__msg:找不到广告位
D/java.lang.Class(21149): 插屏广告加载失败 10002 找不到广告位
I/flutter (21149): 插屏广告失败 10002 找不到广告位

我的广告ID是快手联盟后台直接复制的,没复制错
不过iosId没有我乱填的,应该没关系吧,我是在安卓手机测试


然后我测试了一下激励视频的反倒可以,说明广告id没错,但是插屏广告就是一直提示错误

卡在“Running Gradle task 'assembleDebug'...”了

MacOS 下开发android

flutter pub add ksad
flutter run

卡在


Resolving dependencies...
  collection 1.17.1 (1.17.2 available)
  file 6.1.4 (7.0.0 available)
  matcher 0.12.15 (0.12.16 available)
  material_color_utilities 0.2.0 (0.5.0 available)
  source_span 1.9.1 (1.10.0 available)
  test_api 0.5.1 (0.6.0 available)
  win32 4.1.4 (5.0.3 available)
Got dependencies!
Using hardware rendering with device sdk gphone64 arm64. If you notice graphics artifacts,
consider enabling software rendering with "--enable-software-rendering".
Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
Running Gradle task 'assembleDebug'...                                 ⣷

安装其他包没问题 安装ksad会卡住

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.