Skip to content

Commit 59970e6

Browse files
committed
Merge branch 'master' into 2x
2 parents 34fce50 + 1f69e0a commit 59970e6

File tree

15 files changed

+316
-71
lines changed

15 files changed

+316
-71
lines changed

Diff for: .github/workflows/flutter.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Flutter CI
2+
3+
# This workflow is triggered on pushes to the repository.
4+
5+
on:
6+
push:
7+
branches:
8+
- develop
9+
- master
10+
- 2x
11+
pull_request:
12+
branches:
13+
- develop
14+
- 2x
15+
16+
jobs:
17+
build:
18+
# This job will run on macos virtual machine
19+
runs-on: macos-11
20+
steps:
21+
22+
# Setup Java environment in order to build the Android app.
23+
- uses: actions/checkout@v1
24+
- uses: actions/setup-java@v1
25+
with:
26+
java-version: '8.x'
27+
28+
# Setup the flutter environment.
29+
- uses: subosito/flutter-action@v1
30+
with:
31+
channel: 'stable' # 'dev', 'alpha', default to: 'stable'
32+
#flutter-version: '1.22.x' # you can also specify exact version of flutter
33+
34+
# Get flutter dependencies.
35+
- run: flutter pub get
36+
37+
# Check for any formatting issues in the code.
38+
- run: flutter format --set-exit-if-changed .
39+
40+
# Statically analyze the Dart code for any errors.
41+
- run: flutter analyze .
42+
43+
# Run widget tests for our flutter project.
44+
- run: flutter test
45+
46+
#####
47+
# Build app
48+
#####
49+
# Build apk.
50+
- run: cd example && flutter build apk
51+
# Build ios
52+
- run: cd example && flutter build ios --no-codesign

Diff for: .github/workflows/publish.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Publish
2+
3+
on:
4+
# push:
5+
# branches:
6+
# - develop
7+
# - master
8+
release:
9+
types: [published]
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v1
17+
- name: Publish
18+
uses: sakebook/[email protected]
19+
with:
20+
credential: ${{ secrets.PUB_OAUTH_ACCESS_TOKEN }}
21+
flutter_package: true
22+
skip_test: false
23+
dry_run: false

Diff for: .github/workflows/publish_apk.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish APK
2+
3+
on:
4+
# push:
5+
# branches:
6+
# - develop
7+
# - master
8+
# - 2x
9+
release:
10+
types: [published]
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v1
19+
- name: Setup Java
20+
uses: actions/setup-java@v1
21+
with:
22+
java-version: '8.x'
23+
- name: Setup Flutter
24+
uses: subosito/flutter-action@v1
25+
with:
26+
channel: 'stable' # 'dev', 'alpha', default to: 'stable'
27+
#flutter-version: '1.22.x'
28+
# fix Permission denied
29+
- name: Setup Permission
30+
run: sudo chown -R $USER $PWD
31+
- name: Build APK
32+
run: cd example && flutter build apk --target-platform android-arm
33+
- name: Upload to Pgyer
34+
run: curl -F 'file=@example/build/app/outputs/apk/release/app-release.apk' -F '_api_key=${{ secrets.PGYER_API_KEY }}' https://www.pgyer.com/apiv2/app/upload

Diff for: CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.1.2 [2021-08-29]
2+
* 开屏增加超时时间设置 'fetchDelay' #9
3+
* 开屏 API 变更,logo 参数由位置参数变为可选命名参数,注意修改
4+
15
## 2.1.1 [2021-08-26]
26
* 修复 iOS 使用 use_frameworks! 时编译的错误 #6
37

@@ -16,6 +20,10 @@
1620
* 2.x.x 是 Null Safety 版本
1721
* 现在阶段会同时维护这 2 个版本,再往后可能仅维护一个版本
1822

23+
## 1.1.2 [2021-08-29]
24+
* 开屏增加超时时间设置 'fetchDelay' #9
25+
* 开屏 API 变更,logo 参数由位置参数变为可选命名参数,注意修改
26+
1927
## 1.1.1 [2021-08-26]
2028
* 修复 iOS 使用 use_frameworks! 时编译的错误 #6
2129

Diff for: README.md

+46-60
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
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.1.1-success></a>
8-
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/badge/null_safety-v2.1.1-success></a>
7+
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/badge/version-v1.1.2-success></a>
8+
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/badge/null_safety-v2.1.2-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>
10+
<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>
1011
<a href="https://github.com/FlutterAds/flutter_qq_ads"><img src=https://img.shields.io/github/stars/FlutterAds/flutter_qq_ads?color=brightgreen></a>
1112
<a href="https://github.com/FlutterAds/flutter_qq_ads/blob/develop/LICENSE"><img src=https://img.shields.io/badge/license-MIT-brightgreen></a>
1213
</p>
@@ -27,37 +28,16 @@
2728
- 🔲 Banner
2829
- 🔲 信息流
2930

31+
## 下载体验
32+
<img src="https://www.pgyer.com/app/qrcode/fadsqq" width='100' height='100'>
33+
3034
## 入门使用
3135
### 引入依赖
3236

33-
- 版本约定
34-
* 1.x.x 是非 Null Safety 版本,对应 `master` 分支
35-
* 2.x.x 是 Null Safety 版本,对应 `2x` 分支
36-
37-
> 现在阶段会同时维护这 2 个版本,再往后可能仅维护一个空安全版本
38-
39-
- Pub 引入
40-
4137
``` Dart
4238
dependencies:
43-
flutter_qq_ads: ^1.1.1 # 非 Null Safety 版本
44-
flutter_qq_ads: ^2.1.1 # Null Safety 版本
45-
```
46-
47-
- Git 引入
48-
49-
``` Dart
50-
flutter_qq_ads:
51-
git:
52-
url: [email protected]:FlutterAds/flutter_qq_ads.git
53-
ref: master
54-
```
55-
56-
- 克隆后本地引入
57-
58-
``` Dart
59-
flutter_qq_ads:
60-
path: [与主项目的相对路径 | 插件的绝对路径]
39+
flutter_qq_ads: ^1.1.2 # 非 Null Safety 版本
40+
flutter_qq_ads: ^2.1.2 # Null Safety 版本
6141
```
6242

6343
### 初始化广告
@@ -66,45 +46,19 @@ flutter_qq_ads:
6646
/// [appId] 应用媒体ID
6747
FlutterQqAds.initAd(appId);
6848
```
69-
### 设置广告事件监听
70-
71-
``` Dart
72-
FlutterQqAds.onEventListener((event) {
73-
// 普通广告事件
74-
String _adEvent = 'adId:${event.adId} action:${event.action}';
75-
if (event is AdErrorEvent) {
76-
// 错误事件
77-
_adEvent += ' errCode:${event.errCode} errMsg:${event.errMsg}';
78-
} else if (event is AdRewardEvent) {
79-
// 激励事件
80-
_adEvent +=
81-
' transId:${event.transId} customData:${event.customData} userId:${event.userId}';
82-
}
83-
print('onEventListener:$_adEvent');
84-
});
85-
```
86-
### 事件列表
87-
|事件|说明|
88-
|-|-|
89-
|onAdLoaded|广告加载成功|
90-
|onAdPresent|广告填充|
91-
|onAdExposure|广告曝光|
92-
|onAdClosed|广告关闭(开屏计时结束或者用户点击关闭)|
93-
|onAdClicked|广告点击|
94-
|onAdSkip|广告跳过|
95-
|onAdComplete|广告播放或计时完毕|
96-
|onAdError|广告错误|
97-
|onAdReward|获得广告激励|
98-
99-
> 这里做了统一的抽象,iOS 和 Android 原生 SDK 名称不同,如果觉得对应不上,可以提 [Issues](https://github.com/FlutterAds/flutter_qq_ads/issues)(一定要加上 log 截图)
10049
### 开屏广告
10150

10251
- 半屏广告 + Logo
10352

10453
``` Dart
10554
/// [posId] 广告位 id
10655
/// [logo] 如果传值则展示底部logo,不传不展示,则全屏展示
107-
FlutterQqAds.showSplashAd(posId, 'flutterads_logo');
56+
/// [fetchDelay] 拉取广告的超时时间,默认值 3 秒,取值范围[1.5~5]秒
57+
FlutterQqAds.showSplashAd(
58+
AdsConfig.splashId,
59+
logo: 'flutterads_logo',
60+
fetchDelay: 3,
61+
);
10862
```
10963
- [Logo 设置的最佳实践(必看)](https://github.com/FlutterAds/flutter_qq_ads/blob/develop/doc/SETTING_LOGO.md)
11064

@@ -166,6 +120,38 @@ FlutterQqAds.showRewardVideoAd(
166120
userId: 'userId',
167121
);
168122
```
123+
124+
### 设置广告事件监听
125+
126+
``` Dart
127+
FlutterQqAds.onEventListener((event) {
128+
// 普通广告事件
129+
String _adEvent = 'adId:${event.adId} action:${event.action}';
130+
if (event is AdErrorEvent) {
131+
// 错误事件
132+
_adEvent += ' errCode:${event.errCode} errMsg:${event.errMsg}';
133+
} else if (event is AdRewardEvent) {
134+
// 激励事件
135+
_adEvent +=
136+
' transId:${event.transId} customData:${event.customData} userId:${event.userId}';
137+
}
138+
print('onEventListener:$_adEvent');
139+
});
140+
```
141+
### 事件列表
142+
|事件|说明|
143+
|-|-|
144+
|onAdLoaded|广告加载成功|
145+
|onAdPresent|广告填充|
146+
|onAdExposure|广告曝光|
147+
|onAdClosed|广告关闭(开屏计时结束或者用户点击关闭)|
148+
|onAdClicked|广告点击|
149+
|onAdSkip|广告跳过|
150+
|onAdComplete|广告播放或计时完毕|
151+
|onAdError|广告错误|
152+
|onAdReward|获得广告激励|
153+
154+
> 这里做了统一的抽象,iOS 和 Android 原生 SDK 名称不同,如果觉得对应不上,可以提 [Issues](https://github.com/FlutterAds/flutter_qq_ads/issues)(一定要加上 log 截图)
169155
## 其他配置
170156
### 信任HTTP请求
171157
苹果公司在iOS9中升级了应用网络通信安全策略,默认推荐开发者使用HTTPS协议来进行网络通信,并限制HTTP协议的请求。为了避免出现无法拉取到广告的情况,我们推荐开发者在info.plist文件中增加如下配置来实现广告的网络访问

Diff for: android/src/main/java/com/zero/flutter_qq_ads/PluginDelegate.java

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public static PluginDelegate getInstance() {
3939
public static final String KEY_POSID = "posId";
4040
// logo 参数
4141
public static final String KEY_LOGO = "logo";
42+
// fetchDelay 参数
43+
public static final String KEY_FETCH_DELAY = "fetchDelay";
4244

4345
/**
4446
* 插件代理构造函数构造函数
@@ -144,9 +146,11 @@ public void initAd(MethodCall call, MethodChannel.Result result) {
144146
public void showSplashAd(MethodCall call, MethodChannel.Result result) {
145147
String posId = call.argument(KEY_POSID);
146148
String logo = call.argument(KEY_LOGO);
149+
double fetchDelay = call.argument(KEY_FETCH_DELAY);
147150
Intent intent = new Intent(activity, AdSplashActivity.class);
148151
intent.putExtra(KEY_POSID, posId);
149152
intent.putExtra(KEY_LOGO, logo);
153+
intent.putExtra(KEY_FETCH_DELAY, fetchDelay);
150154
activity.startActivity(intent);
151155
result.success(true);
152156
}

Diff for: android/src/main/java/com/zero/flutter_qq_ads/page/AdSplashActivity.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ private void initData() {
5555
// 获取参数
5656
posId = getIntent().getStringExtra(PluginDelegate.KEY_POSID);
5757
String logo = getIntent().getStringExtra(PluginDelegate.KEY_LOGO);
58+
double fetchDelay = getIntent().getDoubleExtra(PluginDelegate.KEY_FETCH_DELAY,0);
59+
int absFetchDelay= (int) (fetchDelay*1000);
5860
// 创建开屏广告
59-
SplashAD splashAD = new SplashAD(this, posId, this, 0);
61+
SplashAD splashAD = new SplashAD(this, posId, this, absFetchDelay);
6062
if (TextUtils.isEmpty(logo)) {
6163
// logo 为空则加载全屏广告
6264
ad_logo.setVisibility(View.GONE);

Diff for: example/lib/main.dart

+5-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,11 @@ Future<bool> init() async {
206206
/// [logo] 展示如果传递则展示logo,不传递不展示
207207
Future<void> showSplashAd([String? logo]) async {
208208
try {
209-
bool result = await FlutterQqAds.showSplashAd(AdsConfig.splashId, logo);
209+
bool result = await FlutterQqAds.showSplashAd(
210+
AdsConfig.splashId,
211+
logo: logo,
212+
fetchDelay: 3,
213+
);
210214
_result = "展示开屏广告${result ? '成功' : '失败'}";
211215
} on PlatformException catch (e) {
212216
_result = "展示开屏广告失败 code:${e.code} msg:${e.message} details:${e.details}";

Diff for: example/pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ description: FlutterAds 优量汇广告 SDK 插件示例
44
# The following line prevents the package from being accidentally published to
55
# pub.dev using `pub publish`. This is preferred for private packages.
66
publish_to: "none" # Remove this line if you wish to publish to pub.dev
7-
version: 1.0.1+6
7+
version: 2.1.2+8
88

99
environment:
10-
sdk: '>=2.12.0 <3.0.0'
10+
sdk: ">=2.12.0 <3.0.0"
1111

1212
dependencies:
1313
flutter:

Diff for: ios/Classes/Page/SplashPage.m

+3
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ @implementation SplashPage
1818
// 加载广告
1919
-(void)loadAd:(FlutterMethodCall *)call{
2020
NSString* logo=call.arguments[@"logo"];
21+
int fetchDelay=[call.arguments[@"fetchDelay"] intValue];
2122
// logo 判断为空,则全屏展示
2223
self.fullScreenAd=[logo isKindOfClass:[NSNull class]]||[logo length]==0;
2324
// 初始化开屏广告
2425
self.splashAd=[[GDTSplashAd alloc] initWithPlacementId:self.posId];
2526
self.splashAd.delegate=self;
27+
// 设置超时时长
28+
self.splashAd.fetchDelay=fetchDelay;
2629
// 加载全屏广告
2730
if(self.fullScreenAd){
2831
[self.splashAd loadFullScreenAd];

Diff for: ios/flutter_qq_ads.podspec

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
Pod::Spec.new do |s|
66
s.name = 'flutter_qq_ads'
7-
s.version = '2.1.1'
7+
s.version = '2.1.2'
88
s.summary = '一款优质的 Flutter 广告插件(腾讯广告、广点通、优量汇)'
99
s.description = <<-DESC
1010
一款优质的 Flutter 广告插件(腾讯广告、广点通、优量汇).
@@ -20,4 +20,6 @@ Pod::Spec.new do |s|
2020
s.static_framework = true
2121
# 广点通的 SDK 最低支持 9.0 所以,这里设置 9.0
2222
s.ios.deployment_target = '9.0'
23+
# Flutter.framework does not contain a i386 slice.
24+
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
2325
end

Diff for: lib/flutter_qq_ads.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ class FlutterQqAds {
3535
/// 展示开屏广告
3636
/// [posId] 广告位 id
3737
/// [logo] 如果传值则展示底部logo,不传不展示,则全屏展示
38-
static Future<bool> showSplashAd(String posId, [String? logo]) async {
38+
/// [fetchDelay] 拉取广告的超时时间,默认值 3 秒,取值范围[1.5~5]
39+
static Future<bool> showSplashAd(String posId,
40+
{String? logo, double fetchDelay = 3}) async {
3941
final bool result = await _methodChannel.invokeMethod(
4042
'showSplashAd',
4143
{
4244
'posId': posId,
4345
'logo': logo,
46+
'fetchDelay': fetchDelay,
4447
},
4548
);
4649
return result;

Diff for: pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_qq_ads
22
description: FlutterAds 致力于构建优质的 Flutter 广告插件,这是其中一款基于「腾讯广告、广点通、优量汇」SDK 的插件
3-
version: 2.1.1
3+
version: 2.1.2
44
homepage: https://github.com/FlutterAds
55

66
environment:

0 commit comments

Comments
 (0)