Skip to content

Commit

Permalink
📌 更新 SDK 版本
Browse files Browse the repository at this point in the history
  • Loading branch information
BytesZero committed Oct 22, 2023
1 parent afeb532 commit b7cd870
Show file tree
Hide file tree
Showing 25 changed files with 602 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: '8.x'
java-version: '11.x'
# Setup the flutter environment.
- uses: subosito/flutter-action@v1
with:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.7.0 [2023-10-22]
* 🚀 推荐使用【[Gromore](https://flutterads.github.io/site/)】 让您的广告收益最大化
* [更新] Android SDK `v4.542.1412`
* [更新] iOS SDK `v4.14.45`

## 2.6.0 [2023-08-22]
* [更新] Android SDK `v4.540.1410`
* [更新] iOS SDK `v4.14.40`
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
// 广告 SDK
implementation 'com.qq.e.union:union:4.540.1410'
implementation 'com.qq.e.union:union:4.542.1412'
}
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:7.3.0'
}
}

Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
Binary file added example/images/gromore_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/images/gromore_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/images/gromore_pro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/images/pro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
23 changes: 1 addition & 22 deletions example/lib/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ class _HomePageState extends State<HomePage> {
@override
void initState() {
super.initState();
init().then((value) {
if (value) {
showSplashAd(AdsConfig.logo);
}
});
setAdEvent();
}

@override
Expand All @@ -50,9 +44,7 @@ class _HomePageState extends State<HomePage> {
children: [
ElevatedButton(
child: Text('初始化'),
onPressed: () {
init();
},
onPressed: () {},
),
SizedBox(height: 20),
ElevatedButton(
Expand Down Expand Up @@ -239,19 +231,6 @@ class _HomePageState extends State<HomePage> {
}
}

/// 初始化广告 SDK
Future<bool> init() async {
try {
bool result = await FlutterQqAds.initAd(AdsConfig.appId);
_result = "广告SDK 初始化${result ? '成功' : '失败'}";
return result;
} on PlatformException catch (e) {
_result =
"广告SDK 初始化失败 code:${e.code} msg:${e.message} details:${e.details}";
}
return false;
}

/// 展示开屏广告
/// [logo] 展示如果传递则展示logo,不传递不展示
Future<void> showSplashAd([String? logo]) async {
Expand Down
44 changes: 41 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import 'package:flutter/material.dart';
import 'package:flutter_qq_ads_example/home_page.dart';
import 'package:flutter_qq_ads/flutter_qq_ads.dart';

import 'ads_config.dart';
import 'pages/home_page.dart';

void main() {
/// 绑定引擎
// 绑定引擎
WidgetsFlutterBinding.ensureInitialized();
setAdEvent();
init().then((value) {
if (value) {
FlutterQqAds.showSplashAd(
AdsConfig.splashId,
logo: AdsConfig.logo,
);
}
});

// 启动
runApp(MyApp());
}

Expand All @@ -15,6 +29,30 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(home: HomePage());
return MaterialApp(
home: HomePage(),
);
}
}

/// 初始化广告 SDK
Future<bool> init() async {
bool result = await FlutterQqAds.initAd(AdsConfig.appId);
debugPrint("广告SDK 初始化${result ? '成功' : '失败'}");
return result;
}

/// 设置广告监听
Future<void> setAdEvent() async {
FlutterQqAds.onEventListener((event) {
debugPrint('adId:${event.adId} action:${event.action}');
if (event is AdErrorEvent) {
// 错误事件
debugPrint(' errCode:${event.errCode} errMsg:${event.errMsg}');
} else if (event is AdRewardEvent) {
// 激励事件
debugPrint(
' transId:${event.transId} userId:${event.userId} customData:${event.customData}');
}
});
}
37 changes: 37 additions & 0 deletions example/lib/pages/banner_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:flutter/material.dart';
import 'package:flutter_pangle_ads/flutter_pangle_ads.dart';

import '../ads_config.dart';
import '../widgets/widgets.dart';

class BannerPage extends StatefulWidget {
const BannerPage({Key? key}) : super(key: key);

@override
_BannerPageState createState() => _BannerPageState();
}

class _BannerPageState extends State<BannerPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: buildAppBar(context, 'Banner广告'),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(height: 20),
AdBannerWidget(
posId: AdsConfig.bannerId,
width: 300,
height: 80,
interval: 30,
show: true,
),
],
),
),
);
}
}
169 changes: 169 additions & 0 deletions example/lib/pages/feed_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
import 'package:flutter/material.dart';
import 'package:flutter_qq_ads/flutter_qq_ads.dart';
import 'package:loadany/loadany.dart';

import '../ads_config.dart';
import '../widgets/widgets.dart';

/// 信息流页面
class FeedPage extends StatefulWidget {
FeedPage({Key? key}) : super(key: key);

@override
_FeedPageState createState() => _FeedPageState();
}

class _FeedPageState extends State<FeedPage> {
List<int> feedList = [];
List<int> feedAdList = [];

LoadStatus loadStatus = LoadStatus.normal;

@override
void initState() {
getFeedList();
super.initState();
}

@override
void dispose() {
clearFeedAd();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: buildAppBar(context, '信息流广告'),
body: LoadAny(
onLoadMore: () async {
getFeedList();
},
status: loadStatus,
child: CustomScrollView(
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
if (index % 5 == 4) {
int adIndex = index ~/ 5;
if (adIndex >= feedAdList.length) {
return Container(
height: 80,
width: double.maxFinite,
color: Colors.blueAccent,
alignment: Alignment.centerLeft,
child: Text('暂无广告 $index'),
);
}

int adId = feedAdList[adIndex];
return AdFeedWidget(
posId: '$adId',
width: 375,
height: 256,
show: true,
);
}
return LoadingItemWidget();
},
childCount: feedList.length,
),
)
],
),
),
);
}

/// 加载信息流
Future<void> getFeedList() async {
setState(() {
loadStatus = LoadStatus.loading;
});
await Future.delayed(Duration(seconds: 2));
for (var i = 0; i < 30; i++) {
feedList.add(i);
}
getFeedAdList();
}

// 加载信息流广告
Future<void> getFeedAdList() async {
try {
List<int> adResultList = await FlutterQqAds.loadFeedAd(
AdsConfig.feedId,
count: 3,
);
feedAdList.addAll(adResultList);
} catch (e) {
print(e.toString());
}
setState(() {
loadStatus = LoadStatus.normal;
});
}

// 清除信息流广告
Future<void> clearFeedAd() async {
bool result = await FlutterQqAds.clearFeedAd(feedAdList);
print('clearFeedAd:$result');
}
}

/// 加载项组件
class LoadingItemWidget extends StatelessWidget {
const LoadingItemWidget({
Key? key,
}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
height: 80,
width: double.maxFinite,
alignment: Alignment.centerLeft,
padding: EdgeInsets.all(10),
margin: EdgeInsets.symmetric(vertical: 10),
color: Colors.white,
child: Row(
children: [
Container(
width: 60,
height: 60,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Color(0xFFEBEBF4),
),
),
SizedBox(width: 20),
Expanded(
child: Padding(
padding: const EdgeInsets.all(4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: double.maxFinite,
height: 20,
decoration: BoxDecoration(
color: Color(0xFFEBEBF4),
),
),
Spacer(),
Container(
width: 200,
height: 20,
decoration: BoxDecoration(
color: Color(0xFFE4E4F4),
),
),
],
),
),
)
],
),
);
}
}
Loading

0 comments on commit b7cd870

Please sign in to comment.