Skip to content

Commit

Permalink
Merge branch 'release/2.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
BytesZero committed Jan 28, 2023
2 parents 94805e2 + a022d49 commit 4cde39f
Show file tree
Hide file tree
Showing 20 changed files with 128 additions and 293 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.7.0 [2023-01-28]
* [修复] iOS SDK 版本升级后不可用问题 #
* 升级 iOS SDK 到 `v5.0.0.5`
* 升级 Android SDK 到 Pro 版 `v5.1.0.2`
## 2.6.1 [2022-09-06]
* [修复] iOS 开屏广告点击后不跳转的问题
* [修复] Android 激励视频通知两次激励的问题
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<h3 align="center">一款优质的 Flutter 广告插件(字节跳动、巨量引擎、穿山甲)</h3>

<p align="center">
<a href="https://pub.dev/packages/flutter_pangle_ads"><img src=https://img.shields.io/badge/pub-v2.6.1-success></a>
<a href="https://pub.dev/packages/flutter_pangle_ads"><img src=https://img.shields.io/badge/pub-v2.7.0-success></a>
<a href="https://github.com/FlutterAds/flutter_pangle_ads"><img src=https://img.shields.io/badge/platform-iOS%20%7C%20Android-brightgreen></a>
<a href="https://github.com/FlutterAds/flutter_pangle_ads/actions/workflows/flutter.yml"><img src="https://github.com/FlutterAds/flutter_pangle_ads/actions/workflows/flutter.yml/badge.svg"></a>
<a href="https://github.com/FlutterAds/flutter_pangle_ads"><img src=https://img.shields.io/github/stars/FlutterAds/flutter_pangle_ads?color=brightgreen></a>
Expand Down Expand Up @@ -40,7 +40,7 @@

``` Dart
dependencies:
flutter_pangle_ads: ^2.6.1
flutter_pangle_ads: ^2.7.0
```
### 初始化广告

Expand All @@ -51,6 +51,13 @@ import 'package:flutter_pangle_ads/flutter_pangle_ads.dart';
FlutterPangleAds.initAd(appId);
```

### 个性化广告开关

```dart
/// 不调用默认为开,'1'打开,'0'关闭
FlutterPangleAds.setUserExtData(personalAdsType: '1');
```

### 开屏广告

- 全屏
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
// 广告 SDK
implementation 'com.pangle.cn:ads-sdk-pro:4.7.1.2'
implementation 'com.pangle.cn:ads-sdk-pro:5.1.0.2'
// compileOnly fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
import com.zero.flutter_pangle_ads.load.FeedAdManager;
import com.zero.flutter_pangle_ads.page.AdSplashActivity;
import com.zero.flutter_pangle_ads.page.FullScreenVideoPage;
import com.zero.flutter_pangle_ads.page.InterstitialPage;
import com.zero.flutter_pangle_ads.page.NativeViewFactory;
import com.zero.flutter_pangle_ads.page.RewardVideoPage;
import com.zero.flutter_pangle_ads.utils.DataUtils;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -83,8 +85,6 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
initAd(call, result);
} else if ("showSplashAd".equals(method)) {
showSplashAd(call, result);
} else if ("showInterstitialAd".equals(method)) {
showInterstitialAd(call, result);
} else if ("showRewardVideoAd".equals(method)) {
showRewardVideoAd(call, result);
} else if ("showFullScreenVideoAd".equals(method)) {
Expand All @@ -93,6 +93,8 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
loadFeedAd(call, result);
} else if ("clearFeedAd".equals(method)) {
clearFeedAd(call, result);
} else if ("setUserExtData".equals(method)) {
setUserExtData(call, result);
} else {
result.notImplemented();
}
Expand Down Expand Up @@ -229,18 +231,6 @@ public void showSplashAd(MethodCall call, MethodChannel.Result result) {
result.success(true);
}

/**
* 显示插屏广告
*
* @param call MethodCall
* @param result Result
*/
public void showInterstitialAd(MethodCall call, MethodChannel.Result result) {
InterstitialPage adPage = new InterstitialPage();
adPage.showAd(activity, call);
result.success(true);
}

/**
* 显示激励视频广告
*
Expand Down Expand Up @@ -292,4 +282,31 @@ public void clearFeedAd(MethodCall call, MethodChannel.Result result) {
result.success(true);

}

/**
* 个性化推荐广告开关
*
* @param call MethodCall
* @param result Result
*/
public void setUserExtData(MethodCall call, MethodChannel.Result result) {
try {
String personalTypeValue = call.argument("personalAdsType");

JSONArray jsonArray = new JSONArray();
JSONObject personalObject = new JSONObject();
personalObject.put("name", "personal_ads_type");
personalObject.put("value", personalTypeValue);
jsonArray.put(personalObject);

TTAdConfig ttAdConfig = new TTAdConfig.Builder()
.data(jsonArray.toString())
.build();
TTAdSdk.updateAdConfig(ttAdConfig);
result.success(true);
} catch (Exception e) {
e.printStackTrace();
result.success(false);
}
}
}

This file was deleted.

2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ flutter {

dependencies {
// 广告 SDK
// implementation 'com.pangle.cn:ads-sdk-pro:4.7.0.8'
// implementation 'com.pangle.cn:ads-sdk-pro:5.1.0.2'
// implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
platform :ios, '11.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
3 changes: 0 additions & 3 deletions example/lib/ads_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ class AdsConfig {
/// 获取开屏广告位id
static String get splashId => '887870893';

/// 获取插屏广告位id
static String get interstitialId => '949641653';

/// 获取新插屏广告位id
static String get newInterstitialId => '949641653';

Expand Down
33 changes: 4 additions & 29 deletions example/lib/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,6 @@ class _HomePageState extends State<HomePage> {
height: 50,
autoClose: false,
),
SizedBox(height: 20),
ElevatedButton(
child: Text('展示全屏视频广告(已过时)'),
onPressed: () {
showFullScreenVideoAd(AdsConfig.fullScreenVideoId);
},
),
SizedBox(height: 20),
ElevatedButton(
child: Text('展示插屏广告(已过时)'),
onPressed: () {
showInterstitialAd();
},
),
],
),
),
Expand All @@ -170,6 +156,10 @@ class _HomePageState extends State<HomePage> {
],
);
_result = "广告SDK 初始化${result ? '成功' : '失败'}";

// 打开个性化广告推荐
FlutterPangleAds.setUserExtData(personalAdsType: '1');

setState(() {});
return result;
} on PlatformException catch (e) {
Expand Down Expand Up @@ -234,21 +224,6 @@ class _HomePageState extends State<HomePage> {
}
}

/// 展示插屏广告
Future<void> showInterstitialAd() async {
try {
bool result = await FlutterPangleAds.showInterstitialAd(
AdsConfig.interstitialId,
width: 300,
height: 300,
);
_result = "展示插屏广告${result ? '成功' : '失败'}";
} on PlatformException catch (e) {
_result = "展示插屏广告失败 code:${e.code} msg:${e.message} details:${e.details}";
}
setState(() {});
}

/// 展示激励视频广告
Future<void> showRewardVideoAd() async {
try {
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: FlutterAds 穿山甲广告 SDK 插件示例
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: "none" # Remove this line if you wish to publish to pub.dev
version: 2.6.1+16
version: 2.7.0+18

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down
2 changes: 0 additions & 2 deletions ios/Classes/FlutterPangleAdsPlugin.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#import <Flutter/Flutter.h>
#import <BUAdSDK/BUAdSDK.h>
#import "SplashPage.h"
#import "InterstitialPage.h"
#import "RewardVideoPage.h"
#import "FullScreenVideoPage.h"
#import "FeedAdLoad.h"
Expand All @@ -10,7 +9,6 @@
@interface FlutterPangleAdsPlugin : NSObject<FlutterPlugin,FlutterStreamHandler>
@property (strong,nonatomic) FlutterEventSink eventSink;
@property (strong, nonatomic) SplashPage *sad;
@property (strong, nonatomic) InterstitialPage *iad;
@property (strong, nonatomic) RewardVideoPage *rvad;
@property (strong,nonatomic) FullScreenVideoPage *fsad;
@property (strong,nonatomic) FeedAdLoad *fad;
Expand Down
22 changes: 13 additions & 9 deletions ios/Classes/FlutterPangleAdsPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
[self initAd:call result:result];
}else if([@"showSplashAd" isEqualToString:methodStr]) {
[self showSplashAd:call result:result];
}else if ([@"showInterstitialAd" isEqualToString:methodStr]){
[self showInterstitialAd:call result:result];
}else if ([@"showRewardVideoAd" isEqualToString:methodStr]){
[self showRewardVideoAd:call result:result];
}else if ([@"showFullScreenVideoAd" isEqualToString:methodStr]){
Expand All @@ -46,6 +44,8 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
[self loadFeedAd:call result:result];
}else if ([@"clearFeedAd" isEqualToString:methodStr]){
[self clearFeedAd:call result:result];
}else if ([@"setUserExtData" isEqualToString:methodStr]){
[self setUserExtData:call];
}else {
result(FlutterMethodNotImplemented);
}
Expand Down Expand Up @@ -82,13 +82,6 @@ - (void) showSplashAd:(FlutterMethodCall*) call result:(FlutterResult) result{
result(@(YES));
}

// 显示插屏广告
- (void) showInterstitialAd:(FlutterMethodCall*) call result:(FlutterResult) result{
self.iad=[[InterstitialPage alloc] init];
[self.iad showAd:call eventSink:self.eventSink];
result(@(YES));
}

// 显示激励视频广告
- (void) showRewardVideoAd:(FlutterMethodCall*) call result:(FlutterResult) result{
self.rvad=[[RewardVideoPage alloc] init];
Expand Down Expand Up @@ -117,6 +110,17 @@ - (void) clearFeedAd:(FlutterMethodCall*) call result:(FlutterResult) result{
result(@(YES));
}

// 设置个性化推荐
// personalAdsType: String
// 不传或传空或传非01值没任何影响,默认不屏蔽
// 0,屏蔽个性化推荐广告;
// 1,不屏蔽个性化推荐广告
- (void) setUserExtData:(FlutterMethodCall*) call{
NSString *personalAdsType = call.arguments[@"personalAdsType"];
NSString *data = [NSString stringWithFormat:@"[{\"name\":\"personal_ads_type\",\"value\":\"%@\"}]", personalAdsType];
[BUAdSDKManager setUserExtData: data];
}

#pragma mark - FlutterStreamHandler
- (FlutterError * _Nullable)onCancelWithArguments:(id _Nullable)arguments {
self.eventSink=nil;
Expand Down
13 changes: 0 additions & 13 deletions ios/Classes/Page/InterstitialPage.h

This file was deleted.

Loading

0 comments on commit 4cde39f

Please sign in to comment.