mohoflutterplugin 0.0.4 copy "mohoflutterplugin: ^0.0.4" to clipboard
mohoflutterplugin: ^0.0.4 copied to clipboard

This is a moho advertisement SDK

魔盒广告SDK(Flutter版本) #

魔盒广告,支持平台(android,ios),支持广告联盟有(魔盒,穿山甲,优量汇,快手)

使用文档 #

魔盒sdk在使用之前,先需要向我司申请相应的使用权限,以便取得广告ID和Token等信息

Android 相关配置 #

在使用此插件前需要再android平台的//build.gradle 中添加如下代码

allprojects {
    repositories {
        google()
        mavenCentral()
        
        //添加私有库加载地址
        maven {
            url ="http://app.pomoho.com:9012/nexus/content/repositories/mohosdk"
            allowInsecureProtocol = true
        }
    }
}

魔盒最小支持版本为21,请在andorid/app/build.gradle文件中修改支持的最小版本

minSdkVersion 21

SDK初始化 #

使用魔盒sdk之前必须先进行sdk的初始化工作

 final mohoPlugin = Mohoflutterplugin();
 mohoPlugin.initMohoSDk(AppConfig.appID, AppConfig.appToken);

开屏广告 #

import 'package:mohoflutterplugin/event/MohoWidgetListener.dart';
import 'package:mohoflutterplugin/mohoMethodCallHandler.dart';
import 'package:mohoflutterplugin/mohoflutterplugin_platform_interface.dart';


  @override
  Widget build(BuildContext context) {
    var adWidth = MediaQuery.of(context).size.width;
    var adHeight = MediaQuery.of(context).size.height * 0.8;
    return Scaffold(
      appBar: AppBar(title: const Text("开屏广告位")),
      body: Column(
        children: [
          Text(msg),
          MohoSplashAdWidget(
            appId: AppConfig.appID,   
            adId: AppConfig.openID,
            isFullScreen: false, 
            adWidth: adWidth,
            adHeight: adHeight,
            mohoListener: MohoWidgetListener(onLoadSuccess: () {
              setState(() {
                msg = "广告加载成功";
              });
            }, onLoadError: (e) {
              setState(() {
                msg = "广告加载失败$e";
              });
            }, onAdShow: () {
              setState(() {
                msg = "$msg \n 广告显示";
              });
            }, onAdClose: () {
              setState(() {
                msg = "$msg \n 广告已关闭";
              });
            }, onAdClicked: () {
              setState(() {
                msg = "$msg \n 广告被点击";
              });
            }, onRenderingError: (e) {
              setState(() {
                msg = "$msg \n 渲染失败$e";
              });
            }),
          )
        ],
      ),
    );
}
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import 'package:mohoflutterplugin/event/MohoWidgetListener.dart';
import 'package:mohoflutterplugin/mohoMethodCallHandler.dart';
import 'package:mohoflutterplugin/mohoflutterplugin_platform_interface.dart';

 @override
  Widget build(BuildContext context) {
    var adWidth = MediaQuery.of(context).size.width;
    var adHeight = adWidth * 0.3;
    return Scaffold(
      appBar: AppBar(title: const Text("Banner广告位")),
      body: Column(
        children: [
          Text(msg),
          MohoBannerAdWidget(
            appId: AppConfig.appID,
            adId: AppConfig.bannerID,
            adWidth: adWidth,
            adHeight: adHeight,
            mohoListener: MohoWidgetListener(onLoadSuccess: () {
              setState(() {
                msg = " 加载成功";
              });
            }, onLoadError: (e) {
              setState(() {
                msg = "加载失败$e";
              });
            }, onAdShow: () {
              setState(() {
                msg = "$msg \n 广告显示";
              });

            }, onAdClose: () {
              setState(() {
                msg = "$msg \n 广告已关闭";
              });
            }, onAdClicked: () {
              setState(() {
                msg = "$msg \n 广告被点击";
              });
            }, onRenderingError: (e) {
              setState(() {
                msg = "$msg \n 渲染失败$e";
              });

            }),
          ),
        ],
      ),
    );
  }

信息流广告 #

  @override
  Widget build(BuildContext context) {
    var adWidth = MediaQuery.of(context).size.width;
    var adHeight = adWidth * 0.8;
    return Scaffold(
      appBar: AppBar(title: const Text("模板信息流广告位")),
      body: Column(
        children: [
          Text(msg),
          MohoTemplateInfomationFlowAdWidget(
            appId:AppConfig.appID,
            adId: AppConfig.templateAd,
            adWidth: adWidth,
            adHeight: adHeight,
            mohoListener: MohoWidgetListener(onLoadSuccess: () {
              setState(() {
                msg = "加载成功";
              });
            }, onLoadError: (e) {
              setState(() {
                msg = "加载失败$e";
              });
            }, onAdShow: () {
              setState(() {
                msg = "$msg \n 广告显示";
              });
            }, onAdClose: () {
              setState(() {
                msg = "$msg \n 广告已关闭";
              });
            }, onAdClicked: () {
              setState(() {
                msg = "$msg \n 广告被点击";
              });
            }, onRenderingError: (e) {
              setState(() {
                msg = "$msg \n 渲染失败$e";
              });
            }),
          ),

        ],
      ),
    );
  }

draw视频信息流广告 #

 @override
  Widget build(BuildContext context) {
    var adWidth = MediaQuery.of(context).size.width*0.8;
    var adHeight = MediaQuery.of(context).size.height*0.8;
    return Scaffold(
      appBar: AppBar(title: const Text("Draw视频流广告")),
      body: Column(
        children: [
          Text(msg),
          MohoDrawAdWidget(
            appId: AppConfig.appID,
            adId:AppConfig.drawID ,
            adWidth: adWidth,
            adHeight: adHeight,
            mohoListener: MohoWidgetListener(onLoadSuccess: () {
              setState(() {
                msg = "  加载成功";
              });
            }, onLoadError: (e) {
              setState(() {
                msg = " 加载失败$e";
              });
            }, onAdShow: () {
              setState(() {
                msg = "$msg \n 广告显示";
              });

            }, onAdClose: () {
              setState(() {
                msg = "$msg \n 广告已关闭";
              });
            }, onAdClicked: () {
              setState(() {
                msg = "$msg \n 广告被点击";
              });
            }, onRenderingError: (e) {
              setState(() {
                msg = "$msg \n 渲染失败$e";
              });
            }),
          ),

        ],
      ),
    );
  }

插屏广告 #

加载插屏广告

   ad = MohoDialogAd(
        appID:AppConfig.appID ,
        adId: AppConfig.dialogID,
        isMute: true, //是否静音,true是静音
        isFullScreen: false, //是否是全屏类型
        mohoLoadListener: MohoLoadListener(onLoadError: (e) { //加载回调

          setState(() {
            isShow = false;
            msg="插屏广告加载失败$e";
          });
        }, onLoadSuccess: () {
          setState(() {
            isShow = true;
            msg="插屏广告加载成功!!!";
          });
        }),
        mohoRenderingListener: MohoRenderingListener( //渲染回调
          onAdClicked: () {
            setState(() {
              isShow = false;
              msg="广告被点击";
            });
          },
          onAdClose: () {
            setState(() {
              isShow = false;
              msg="广告关闭";
            });
          },
          onRenderingError: (e) {
            setState(() {
              isShow = false;
              msg="插屏渲染失败$e";
            });
          },
          onAdShow: () {
            setState(() {
              isShow = false;
              msg="插屏广告展示";
            });
          },
        ));
    ad?.load();
    

广告在调用onLoadSuccess成功之后可以进行显示

 ad?.show();

激励广告 #

 ad = MohoRewardAd(
        appID: AppConfig.appID,
        adId: AppConfig.rewardID,
        mohoLoadListener: MohoLoadListener(onLoadError: (e) {
          setState(() {
            isShow = false;
            msg="激励视频广告加载失败$e";
          });
        }, onLoadSuccess: () {
          setState(() {
            isShow = true;
            msg="激励视频广告加载成功!!!";
          });
        }),
        mohoRenderingListener: MohoRewardRenderingListener(
          onAdClicked: () {
            setState(() {
              isShow = false;
              msg="激励视频广告被点击";
            });
          },
          onAdClose: () {
            setState(() {
              isShow = false;
              msg="激励视频广告关闭";
            });
          },
          onRenderingError: (e) {
            setState(() {
              isShow = false;
              msg="激励视频渲染失败$e";
            });
          },
          onAdVideoComplete: (){
            setState(() {
              isShow = false;
              msg="激励视频播放完成";
            });
          },
          onRewardVerify: (){
            setState(() {
              isShow = false;
              msg="激励视频奖励回调";
            });
          },
          onAdShow: () {
            setState(() {
              isShow = false;
              msg="激励视频曝光";
            });
          },
        ));
    ad?.load();

广告在调用onLoadSuccess成功之后可以进行显示

 ad?.show();
2
likes
0
points
32
downloads

Publisher

unverified uploader

Weekly Downloads

This is a moho advertisement SDK

Homepage

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on mohoflutterplugin