Skip to content

Commit 620d799

Browse files
committed
Merge branch 'release/1.4.0'
2 parents b7d239a + 00b4023 commit 620d799

37 files changed

+1748
-304
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
* 2.x.x 是 Null Safety 版本
44
* 现在阶段会同时维护这 2 个版本,再往后可能仅维护一个版本
55

6+
## 1.4.0 [2021-12-05]
7+
* 新增 `信息流` 广告
8+
* 优化 `Banner` 广告内部增加宽高设置,不在需要外部嵌套一层约束组件
9+
* 优化统一底层架构
10+
* 更新 Android SDK `v4.430.1300`
11+
612
## 1.3.0 [2021-09-26]
713
* 修复同时引入 [flutter_pangle_ads](https://github.com/FlutterAds/flutter_pangle_ads) 依赖时 iOS 无法编译的问题 #11
814
* 优化底层架构

README.md

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<h3 align="center">一款优质的 Flutter 广告插件(腾讯广告、广点通、优量汇)</h3>
55

66
<p align="center">
7-
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/badge/version-v1.3.0-success></a>
8-
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/badge/null_safety-v2.3.0-success></a>
7+
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/badge/version-v1.4.0-success></a>
8+
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/badge/null_safety-v2.4.0-success></a>
99
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/badge/platform-iOS%20%7C%20Android-brightgreen></a>
1010
<a href="https://github.com/FlutterAds/flutter_qq_ads/actions/workflows/flutter.yml"><img src="https://github.com/FlutterAds/flutter_qq_ads/actions/workflows/flutter.yml/badge.svg?branch=develop"></a>
1111
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/github/stars/FlutterAds/flutter_qq_ads?color=brightgreen></a>
@@ -15,7 +15,7 @@
1515
## 插件特点
1616
- 🔨 接入简单快速(封装原生端配置,仅需引入即可开始)
1717
- 📡 事件统一返回(将原生端各种重要回调事件统一返回,方便业务处理和埋点统计等需求)
18-
- 🎁 注重优化体验(无闪烁 Logo 开屏、权限申请、隐私跟踪申请等)
18+
- 🎁 注重优化体验(无闪烁 Logo 开屏、权限申请、隐私跟踪申请等、信息流自动适配宽高
1919
- 🏆 极客代码封装(原生端代码不凑合,两端统一基础框架、广告事件封装抽象、易扩展新广告形式、方便开发个性化需求)
2020

2121
## 支持功能
@@ -26,7 +26,7 @@
2626
- ✅ 激励视频
2727
-[激励视频](#激励视频)
2828
-[Banner](#Banner)
29-
- 🔲 信息流
29+
- [信息流](#信息流)
3030

3131
## 下载体验
3232
<a href="https://www.pgyer.com/app/qrcode/fadsqq"><img src="https://www.pgyer.com/app/qrcode/fadsqq" width='100' height='100'></a>
@@ -36,8 +36,8 @@
3636

3737
``` Dart
3838
dependencies:
39-
flutter_qq_ads: ^1.3.0 # 非 Null Safety 版本
40-
flutter_qq_ads: ^2.3.0 # Null Safety 版本
39+
flutter_qq_ads: ^1.4.0 # 非 Null Safety 版本
40+
flutter_qq_ads: ^2.4.0 # Null Safety 版本
4141
```
4242

4343
### 初始化广告
@@ -125,57 +125,75 @@ FlutterQqAds.showRewardVideoAd(
125125
### Banner
126126
``` Dart
127127
/// [posId] 广告位 id
128+
/// [width] 宽度
129+
/// [height] 高度
128130
/// [interval] 广告刷新间隔,0 或[30~120]之间的数字,单位为 s,默认 30s
129131
/// Android:0 表示不自动轮播
130132
/// iOS:0 表示关闭轮播动画,因为 iOS 没有不轮播
131133
/// [show] 是否显示广告
132134
AdBannerWidget(
133135
posId: AdsConfig.bannerId02,
134-
interval: 120,
136+
width: 375,
137+
height: 100,
138+
interval: 120,
135139
show: true,
136140
)
137141
```
142+
> `v1.4.0` 开始不再需要外部嵌套,如果需要按比例设置,可以看如下示例:
138143
139-
Banner 广告外部需要嵌套一个带有约束布局的 Widget,如:`AspectRatio、SizedBox、Container` 等,示例如下:
140-
141-
- 嵌套 `AspectRatio` (推荐)
144+
- 嵌套宽高比约束布局 `AspectRatio`
142145

143146
``` Dart
144147
AspectRatio(
145148
aspectRatio: 6.4 / 1, // 6.4:1 的比例
146149
child: AdBannerWidget(
147150
posId: AdsConfig.bannerId02,
151+
width: double.maxFinite,
152+
height: double.maxFinite,
148153
interval: 120,
149154
),
150155
),
151156
```
152157

153-
- 嵌套 `SizedBox`
154-
158+
### 信息流
159+
- 获取信息流广告列表
155160
``` Dart
156-
SizedBox(
157-
width: 375,
158-
height: 100,
159-
child: AdBannerWidget(
160-
posId: AdsConfig.bannerId01,
161-
),
162-
)
161+
/// [posId] 广告位 id
162+
/// [width] 宽度
163+
/// [height] 高度,0:代表自适应广告高度
164+
/// [count] 获取广告数量,建议 1~3 个
165+
List<int> feedAdList = await FlutterPangleAds.loadFeedAd(
166+
AdsConfig.feedId,
167+
width: 375,
168+
height: 0,
169+
count: 3,
170+
);
163171
```
172+
- 清除信息流广告列表
164173

165-
- 嵌套 `Container`
174+
> 当你的广告不再需要时,请一定执行清除操作
175+
``` Dart
176+
/// [list] 信息流广告 id 列表
177+
bool result = await FlutterPangleAds.clearFeedAd(feedAdList);
178+
```
179+
- 页面中展示信息流广告
166180

167181
``` Dart
168-
Container(
169-
width: double.infinity,
170-
height: 80,
171-
child: AdBannerWidget(
172-
posId: AdsConfig.bannerId,
173-
interval: 0,
182+
/// Feed 信息流广告组件
183+
/// [posId]返回的广告 id,这里不是广告位id
184+
/// [width]组件的宽度
185+
/// [height]组件的高度
186+
/// [show]是否显示
187+
AdFeedWidget(
188+
posId: '${feedAdList[0]}',
189+
width: 375,
190+
height: 128,
174191
show: true,
175-
),
176-
)
192+
)
177193
```
178194

195+
> `width``height` 只是展示 widget 组件宽高,最终会自动适配实际广告的宽高,不可设置为 0
196+
179197
### 设置广告事件监听
180198

181199
``` Dart
@@ -288,4 +306,4 @@ pod install
288306
|-|-|
289307
|[flutter_qq_ads](https://github.com/FlutterAds/flutter_qq_ads)|腾讯广告、广点通、优量汇 Flutter 广告插件|
290308
|[flutter_pangle_ads](https://github.com/FlutterAds/flutter_pangle_ads)|字节跳动、穿山甲 Flutter 广告插件|
291-
|flutter_baidu_ads|百度、百青藤 Flutter 广告插件(开发中)|
309+
|[flutter_gromore_ads](https://github.com/FlutterAds/flutter_gromore_ads)|字节跳动、穿山甲、Gromore 聚合 Flutter 广告插件(开发中)|

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ dependencies {
3838
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
3939
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
4040
// 广告 SDK
41-
implementation 'com.qq.e.union:union:4.410.1280'
41+
implementation 'com.qq.e.union:union:4.430.1300'
4242
}

android/src/main/java/com/zero/flutter_qq_ads/FlutterQqAdsPlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public void onAttachedToActivity(@NonNull ActivityPluginBinding binding) {
4444
methodChannel.setMethodCallHandler(delegate);
4545
eventChannel.setStreamHandler(delegate);
4646
this.delegate.registerBannerView();
47+
this.delegate.registerFeedView();
4748
}
4849

4950
@Override

android/src/main/java/com/zero/flutter_qq_ads/PluginDelegate.java

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88

99
import com.qq.e.comm.managers.GDTADManager;
1010
import com.qq.e.comm.managers.GDTAdSdk;
11+
import com.zero.flutter_qq_ads.load.FeedAdLoad;
12+
import com.zero.flutter_qq_ads.load.FeedAdManager;
1113
import com.zero.flutter_qq_ads.page.AdSplashActivity;
1214
import com.zero.flutter_qq_ads.page.InterstitialPage;
1315
import com.zero.flutter_qq_ads.page.NativeViewFactory;
1416
import com.zero.flutter_qq_ads.page.RewardVideoPage;
1517

18+
import java.util.List;
19+
1620
import io.flutter.embedding.engine.plugins.FlutterPlugin;
1721
import io.flutter.plugin.common.EventChannel;
1822
import io.flutter.plugin.common.MethodCall;
@@ -37,6 +41,8 @@ public static PluginDelegate getInstance() {
3741
}
3842
// Banner View
3943
public static final String KEY_BANNER_VIEW = "flutter_qq_ads_banner";
44+
// Feed View
45+
public static final String KEY_FEED_VIEW = "flutter_qq_ads_feed";
4046
// 广告参数
4147
public static final String KEY_POSID = "posId";
4248
// logo 参数
@@ -76,7 +82,11 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
7682
showInterstitialAd(call, result);
7783
} else if ("showRewardVideoAd".equals(method)) {
7884
showRewardVideoAd(call, result);
79-
} else {
85+
}else if ("loadFeedAd".equals(method)) {
86+
loadFeedAd(call, result);
87+
} else if ("clearFeedAd".equals(method)) {
88+
clearFeedAd(call, result);
89+
} else {
8090
result.notImplemented();
8191
}
8292
}
@@ -135,6 +145,14 @@ public void registerBannerView() {
135145
.registerViewFactory(KEY_BANNER_VIEW, new NativeViewFactory(KEY_BANNER_VIEW,this));
136146
}
137147

148+
/**
149+
* 注册 Feed 信息流广告
150+
*/
151+
public void registerFeedView() {
152+
bind.getPlatformViewRegistry()
153+
.registerViewFactory(KEY_FEED_VIEW, new NativeViewFactory(KEY_FEED_VIEW, this));
154+
}
155+
138156
/**
139157
* 初始化广告
140158
*
@@ -172,9 +190,8 @@ public void showSplashAd(MethodCall call, MethodChannel.Result result) {
172190
* @param result Result
173191
*/
174192
public void showInterstitialAd(MethodCall call, MethodChannel.Result result) {
175-
String posId = call.argument(KEY_POSID);
176193
InterstitialPage iad = new InterstitialPage();
177-
iad.showAd(activity, posId, call);
194+
iad.showAd(activity, call);
178195
result.success(true);
179196
}
180197

@@ -185,9 +202,36 @@ public void showInterstitialAd(MethodCall call, MethodChannel.Result result) {
185202
* @param result Result
186203
*/
187204
public void showRewardVideoAd(MethodCall call, MethodChannel.Result result) {
188-
String posId = call.argument(KEY_POSID);
189205
RewardVideoPage iad = new RewardVideoPage();
190-
iad.showAd(activity, posId, call);
206+
iad.showAd(activity, call);
191207
result.success(true);
192208
}
209+
210+
/**
211+
* 加载信息流广告列表
212+
*
213+
* @param call MethodCall
214+
* @param result Result
215+
*/
216+
public void loadFeedAd(MethodCall call, MethodChannel.Result result) {
217+
FeedAdLoad feedAd = new FeedAdLoad();
218+
feedAd.loadFeedAdList(activity, call, result);
219+
}
220+
221+
/**
222+
* 删除信息流广告列表
223+
*
224+
* @param call MethodCall
225+
* @param result Result
226+
*/
227+
public void clearFeedAd(MethodCall call, MethodChannel.Result result) {
228+
List<Integer> adList = call.argument("list");
229+
if (adList != null) {
230+
for (int ad : adList) {
231+
FeedAdManager.getInstance().removeAd(ad);
232+
}
233+
}
234+
result.success(true);
235+
236+
}
193237
}

0 commit comments

Comments
 (0)