flutter_unionad 0.0.3
flutter_unionad: ^0.0.3

Flutter Android iOS

A new flutter plugin for Bytedance-UnionAD

穿山甲广告 flutter版本 #

image

简介 #

flutter_unioad是一款集成了穿山甲Android和iOSSDK的Flutter插件,方便直接调用穿山甲SDK方法开发

官方文档 #

集成步骤 #

1、pubspec.yaml

flutter_unionad: ^0.0.1

2、Android

aar文件已集成进插件中无需额外配置,只需要在android目录中AndroidManifest.xml配置

  <application
        tools:replace="android:label">

SDK版本 3.2.0.3

3、IOS

SDK已配置插件中,其余根据SDK文档配置,因为使用PlatformView,在Info.plist加入

 <key>io.flutter.embedded_views_preview</key>
    <true/>

SDK版本 3.2.0.1

使用 #

1、SDK初始化

await FlutterUnionad.register(
        androidAppId: "5098580",
        iosAppId:  "5098580",
        useTextureView: true,
        appName: "unionad_test",
        allowShowNotify: true,
        allowShowPageWhenScreenLock: true,
        debug: true,
        supportMultiProcess: true,
        directDownloadNetworkType: [
          FlutterUnionad.NETWORK_STATE_2G,
          FlutterUnionad.NETWORK_STATE_3G,
          FlutterUnionad.NETWORK_STATE_4G,
          FlutterUnionad.NETWORK_STATE_WIFI
        ]);

2、获取SDK版本

await FlutterUnionad.getSDKVersion();

3、请求权限

await FlutterUnionad.requestPermissionIfNecessary();

4、开屏广告

Container(
            height: 700,
            child: FlutterUnionad.splashAdView(
                mCodeId: "887367774",
                supportDeepLink: true,
                mIsExpress: false,
                expressViewWidth: 540,
                expressViewHeight: 800),
          ),

监听开屏广告状态

 StreamSubscription _adViewStream = FlutterUnionad.adeventEvent
        .receiveBroadcastStream()
        .listen((data) {
      if (data[FlutterUnionad.adType] == FlutterUnionad.aplashAd) {
        if (data[FlutterUnionad.aplashType] == FlutterUnionad.onAplashTimeout) {
          print("开屏广告超时  ${FlutterUnionad.onAplashTimeout}");
        } else if (data[FlutterUnionad.aplashType] ==
            FlutterUnionad.onAplashShow) {
          print("开屏广告显示  ${FlutterUnionad.onAplashShow}");
        } else if (data[FlutterUnionad.aplashType] ==
            FlutterUnionad.onAplashClick) {
          print("开屏广告点击  ${FlutterUnionad.onAplashClick}");
        } else if (data[FlutterUnionad.aplashType] ==
            FlutterUnionad.onAplashSkip) {
          print("开屏广告跳过  ${FlutterUnionad.onAplashSkip}");
          Navigator.pop(context);
        } else if (data[FlutterUnionad.aplashType] ==
            FlutterUnionad.onAplashFinish) {
          print("开屏广告结束  ${FlutterUnionad.onAplashFinish}");
          Navigator.pop(context);
        }
      }
    });

5、banner广告

Container(
              height: 200,
              child: FlutterUnionad.bannerAdView(
                mCodeId: "945410197",
                supportDeepLink: true,
                expressAdNum: 3,
                expressTime: 30,
                expressViewWidth: 1080,
                expressViewHeight: 400,
              ),
            ),

6、信息流广告

 Container(
              height: 300,
              child: FlutterUnionad.nativeExpressAdView(
                mCodeId: "945417699",
                supportDeepLink: true,
                expressViewWidth: 800,
                expressViewHeight: 600,
              ),
            ), 

7、插屏广告

返回原生view

FlutterUnionad.interactionExpressAdView(
                  mCodeId: "945417892",
                  supportDeepLink: true,
                  expressViewWidth: 800,
                  expressViewHeight: 1200,
                );

直接弹窗

FlutterUnionad.interactionExpressAd(
                  mCodeId: "945417892",
                  supportDeepLink: true,
                  expressViewWidth: 800,
                  expressViewHeight: 1200,
                );

8、激励视频

FlutterUnionad.loadRewardVideoAd(
                    mIsExpress: true,
                    mCodeId: "945418088",
                    supportDeepLink: true,
                    rewardName: "100金币",
                    rewardAmount: 100,
                    userID: "123",
                    orientation: FlutterUnionad.VideoVERTICAL,
                    mediaExtra: null);

9、draw视频广告

Center(
              child: FlutterUnionad.drawFeedExpressAdView(
                  mCodeId: "945426252",
                  supportDeepLink: true,
                  expressViewWidth: 1080,
                  expressViewHeight: 1920),
            );
          },

历史版本 #

| 版本 | 说明 | | :------------ |:---------------:| | 0.0.1 | 增加Android各广告的使用,新增ios激励广告 |

说明 #

目前项目中只用到了激励视频,所以该插件只完善了激励视频相关的操作; android部分均已完善各个性化广告的使用,ios部分只做了激励视频, 接下来有空会陆续完善插件。<br/> 如果有什么建议可以联系我的邮箱 gstory0404@163.com

2
likes
80
pub points
15%
popularity

A new flutter plugin for Bytedance-UnionAD

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

gstory0404@gmail.com

License

Apache 2.0 (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_unionad