Skip to content

Commit

Permalink
Merge branch 'release/2.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
BytesZero committed Sep 2, 2022
2 parents 5b4653c + 1ea6fc6 commit ca2d21a
Showing 23 changed files with 389 additions and 240 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.6.0 [2022-09-02]
* [升级] 适配 4700 SDK 版本[#30](https://github.com/FlutterAds/flutter_pangle_ads/issues/30)
* [新增] 新增进阶激励视频支持[#31](https://github.com/FlutterAds/flutter_pangle_ads/issues/31)
* [升级] iOS SDK 到 `v4.7.0.8`
* [升级] Android SDK 到 Pro 版 `v4.7.1.2`

## 2.5.0 [2022-03-18]
* [修复] `splashButtonType` 新版 SKD 不存在的问题 [#20](https://github.com/FlutterAds/flutter_pangle_ads/issues/20)
* 升级 iOS SDK 到 `v4.3.0.4`
45 changes: 23 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<p align="center">
<a href="https://github.com/FlutterAds"><img src="https://raw.githubusercontent.com/FlutterAds/site/master/logo/flutterads_logo.png" alt="logo" height="180"/></a>
</p>
<h3 align="center">一款优质的 Flutter 广告插件(字节跳动、穿山甲)</h3>
<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.5.0-success></a>
<a href="https://pub.dev/packages/flutter_pangle_ads"><img src=https://img.shields.io/badge/pub-v2.6.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>
@@ -19,13 +19,15 @@

## 支持功能
- ✅ 开屏广告
-插屏广告
-半插屏
-全屏视频(新插屏)
-新插屏广告
-半屏
-全屏
- ✅ 激励视频
- ✅ 全屏视频
- ✅ 普通激励
- ✅ 进阶激励
- ✅ Banner
- ✅ 信息流
- ✅ 全屏视频(已废弃)
- 🔲 Draw 贴片视频

## 下载体验
@@ -38,7 +40,7 @@

``` Dart
dependencies:
flutter_pangle_ads: ^2.5.0
flutter_pangle_ads: ^2.6.0
```
### 初始化广告

@@ -65,12 +67,11 @@ FlutterPangleAds.showSplashAd(
);
```

- 全屏广告

- 全屏开屏广告
``` Dart
FlutterQqAds.showSplashAd(posId);
```
### 插屏广告
### 新插屏广告
``` Dart
/// [posId] 广告位 id
/// [width] 请求模板广告素材的尺寸宽度(对应 expressViewWidth 参数)
@@ -94,15 +95,6 @@ FlutterPangleAds.showRewardVideoAd(
);
```

### 全屏视频
- 全屏视频
- 新插屏
``` Dart
/// [posId] 广告位 id
FlutterPangleAds.showFullScreenVideoAd(AdsConfig.fullScreenVideoId);
```


### Banner
``` Dart
/// [posId] 广告位 id
@@ -176,6 +168,15 @@ AdFeedWidget(
```
> `width``height` 需要根据你新建广告位的模板来设置
### 全屏视频(已废弃)
> 建议使用新插屏
``` Dart
/// [posId] 广告位 id
FlutterPangleAds.showFullScreenVideoAd(AdsConfig.fullScreenVideoId);
```


### 设置广告事件监听

``` Dart
@@ -188,7 +189,7 @@ FlutterPangleAds.onEventListener((event) {
} else if (event is AdRewardEvent) {
// 激励事件
_adEvent +=
' rewardVerify:${event.rewardVerify} rewardAmount:${event.rewardAmount} rewardName:${event.rewardName} errCode:${event.errCode} errMsg:${event.errMsg} customData:${event.customData} userId:${event.userId}';
'rewardType:${event.rewardType} rewardVerify:${event.rewardVerify} rewardAmount:${event.rewardAmount} rewardName:${event.rewardName} errCode:${event.errCode} errMsg:${event.errMsg} customData:${event.customData} userId:${event.userId}';
}
// 测试关闭 Banner(会员场景)
if (event.action == AdEventAction.onAdClosed &&
@@ -305,6 +306,6 @@ pod install
|插件|描述|
|-|-|
|[flutter_qq_ads](https://github.com/FlutterAds/flutter_qq_ads)|腾讯广告、广点通、优量汇 Flutter 广告插件|
|[flutter_pangle_ads](https://github.com/FlutterAds/flutter_pangle_ads)|字节跳动、穿山甲 Flutter 广告插件|
|[flutter_gromore_ads](https://github.com/FlutterAds/flutter_gromore_ads)|字节跳动、穿山甲、Gromore 聚合 Flutter 广告插件|
|[flutter_pangle_ads](https://github.com/FlutterAds/flutter_pangle_ads)|字节跳动、巨量引擎、穿山甲 Flutter 广告插件|
|[flutter_gromore_ads](https://github.com/FlutterAds/flutter_gromore_ads)|字节跳动、巨量引擎、穿山甲、Gromore 聚合 Flutter 广告插件|

11 changes: 6 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ buildscript {
}

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

@@ -34,10 +34,11 @@ android {
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
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.3.0.8'
implementation 'com.pangle.cn:ads-sdk-pro:4.7.1.2'
// compileOnly fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}
Original file line number Diff line number Diff line change
@@ -6,6 +6,9 @@
* 广告激励事件
*/
public class AdRewardEvent extends AdEvent {

// 奖励类型
private final int rewardType;
// 奖励是否有效
private final boolean rewardVerify;
// 奖励数量
@@ -21,8 +24,9 @@ public class AdRewardEvent extends AdEvent {
// 用户信息
private final String userId;

public AdRewardEvent(String adId, boolean rewardVerify, int rewardAmount, String rewardName, int errCode, String errMsg, String customData, String userId) {
public AdRewardEvent(String adId, int rewardType,boolean rewardVerify, int rewardAmount, String rewardName, int errCode, String errMsg, String customData, String userId) {
super(adId, AdEventAction.onAdReward);
this.rewardType=rewardType;
this.rewardVerify = rewardVerify;
this.rewardAmount = rewardAmount;
this.rewardName = rewardName;
@@ -35,6 +39,7 @@ public AdRewardEvent(String adId, boolean rewardVerify, int rewardAmount, String
@Override
public HashMap<String, Object> toMap() {
HashMap<String, Object> newMap = super.toMap();
newMap.put("rewardType", rewardType);
newMap.put("rewardVerify", rewardVerify);
newMap.put("rewardAmount", rewardAmount);
newMap.put("rewardName", rewardName);
Original file line number Diff line number Diff line change
@@ -11,10 +11,11 @@
import androidx.appcompat.widget.AppCompatImageView;

import com.bytedance.sdk.openadsdk.AdSlot;
import com.bytedance.sdk.openadsdk.TTAdConstant;
import com.bytedance.sdk.openadsdk.CSJAdError;
import com.bytedance.sdk.openadsdk.CSJSplashAd;
import com.bytedance.sdk.openadsdk.TTAdLoadType;
import com.bytedance.sdk.openadsdk.TTAdNative;
import com.bytedance.sdk.openadsdk.TTAdSdk;
import com.bytedance.sdk.openadsdk.TTSplashAd;
import com.zero.flutter_pangle_ads.PluginDelegate;
import com.zero.flutter_pangle_ads.R;
import com.zero.flutter_pangle_ads.event.AdErrorEvent;
@@ -27,7 +28,7 @@
/**
* 开屏广告
*/
public class AdSplashActivity extends AppCompatActivity implements TTAdNative.SplashAdListener, TTSplashAd.AdInteractionListener {
public class AdSplashActivity extends AppCompatActivity implements TTAdNative.CSJSplashAdListener, CSJSplashAd.SplashAdListener {
private final String TAG = AdSplashActivity.class.getSimpleName();
// 广告容器
private FrameLayout ad_container;
@@ -76,8 +77,9 @@ private void initData() {
Log.e(TAG, "Logo 名称不匹配或不在 mipmap 文件夹下,展示全屏");
}
}
int width = (int) UIUtils.getScreenWidthInPx(this);
int height = (int) UIUtils.getScreenHeightInPx(this);
int width = UIUtils.getScreenWidthInPx(this);
int widthDp = (int) UIUtils.getScreenWidthDp(this);
int height = UIUtils.getRealHeight(this);
// 判断最终的 Logo 是否显示
if (!hasLogo) {
ad_logo.setVisibility(View.GONE);
@@ -90,10 +92,12 @@ private void initData() {
AdSlot adSlot = new AdSlot.Builder()
.setCodeId(posId)
.setSupportDeepLink(true)
.setImageAcceptedSize(width, height)
.setImageAcceptedSize(width, height) // 单位是px
.setExpressViewAcceptedSize(widthDp, UIUtils.px2dip(this,height)) // 单位是dp
.setAdLoadType(TTAdLoadType.LOAD)
.build();
// 加载广告
splashAD.loadSplashAd(adSlot, this, absTimeout);
splashAD.loadSplashAd(adSlot,this,absTimeout);
}

/**
@@ -127,59 +131,57 @@ private int getMipmapId(String resName) {
}

@Override
public void onError(int i, String s) {
Log.e(TAG, "onError code:" + i + " msg:" + s);
AdEventHandler.getInstance().sendEvent(new AdErrorEvent(this.posId, i, s));
finishPage();
public void onSplashLoadSuccess() {
Log.d(TAG, "onSplashLoadSuccess");
// 加载事件
AdEventHandler.getInstance().sendEvent(new AdEvent(this.posId, AdEventAction.onAdLoaded));
}

@Override
public void onTimeout() {
Log.d(TAG, "onTimeout");
AdEventHandler.getInstance().sendEvent(new AdErrorEvent(this.posId, -100, "loadSplashAd onTimeout"));
public void onSplashLoadFail(CSJAdError error) {
AdEventHandler.getInstance().sendEvent(new AdErrorEvent(this.posId, error.getCode(), error.getMsg()));
finishPage();
}

@Override
public void onSplashAdLoad(TTSplashAd ad) {
public void onSplashRenderSuccess(CSJSplashAd csjSplashAd) {
Log.d(TAG, "onSplashAdLoad");
//获取SplashView
View view = ad.getSplashView();
if (!this.isFinishing()) {
ad_container.removeAllViews();
ad_container.addView(view);
} else {
if (this.isFinishing()) {
AdEventHandler.getInstance().sendEvent(new AdEvent(this.posId, AdEventAction.onAdClosed));
finishPage();
} else {
csjSplashAd.showSplashView(ad_container);
// 设置交互监听
csjSplashAd.setSplashAdListener(this);
// 加载事件
AdEventHandler.getInstance().sendEvent(new AdEvent(this.posId, AdEventAction.onAdPresent));
}
// 设置交互监听
ad.setSplashInteractionListener(this);
// 加载事件
AdEventHandler.getInstance().sendEvent(new AdEvent(this.posId, AdEventAction.onAdLoaded));

}

@Override
public void onAdClicked(View view, int i) {
Log.d(TAG, "onAdClicked");
AdEventHandler.getInstance().sendEvent(new AdEvent(this.posId, AdEventAction.onAdClicked));
public void onSplashRenderFail(CSJSplashAd csjSplashAd, CSJAdError error) {
AdEventHandler.getInstance().sendEvent(new AdErrorEvent(this.posId, error.getCode(), error.getMsg()));
finishPage();
}

@Override
public void onAdShow(View view, int i) {
Log.d(TAG, "onAdShow");
public void onSplashAdShow(CSJSplashAd csjSplashAd) {
Log.d(TAG, "onSplashLoadSuccess");
AdEventHandler.getInstance().sendEvent(new AdEvent(this.posId, AdEventAction.onAdExposure));
}

@Override
public void onAdSkip() {
Log.d(TAG, "onAdSkip");
AdEventHandler.getInstance().sendEvent(new AdEvent(this.posId, AdEventAction.onAdSkip));
public void onSplashAdClick(CSJSplashAd csjSplashAd) {
Log.d(TAG, "onSplashAdClick");
AdEventHandler.getInstance().sendEvent(new AdEvent(this.posId, AdEventAction.onAdClicked));
finishPage();
}

@Override
public void onAdTimeOver() {
Log.d(TAG, "onAdTimeOver");
AdEventHandler.getInstance().sendEvent(new AdEvent(this.posId, AdEventAction.onAdComplete));
public void onSplashAdClose(CSJSplashAd csjSplashAd, int i) {
Log.d(TAG, "onSplashAdClose");
AdEventHandler.getInstance().sendEvent(new AdEvent(this.posId, AdEventAction.onAdClosed));
finishPage();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.zero.flutter_pangle_ads.page;

import android.os.Bundle;
import android.util.Log;

import androidx.annotation.NonNull;
@@ -9,6 +10,7 @@
import com.bytedance.sdk.openadsdk.TTRewardVideoAd;
import com.zero.flutter_pangle_ads.event.AdEventAction;
import com.zero.flutter_pangle_ads.event.AdRewardEvent;
import com.zero.flutter_pangle_ads.utils.RewardBundleModel;

import io.flutter.plugin.common.MethodCall;

@@ -51,6 +53,7 @@ public void onRewardVideoAdLoad(TTRewardVideoAd ttRewardVideoAd) {
Log.i(TAG, "onRewardVideoAdLoad");
rvad = ttRewardVideoAd;
rvad.setRewardAdInteractionListener(this);
rvad.setRewardPlayAgainInteractionListener(this);
// 添加广告事件
sendEvent(AdEventAction.onAdLoaded);
}
@@ -107,10 +110,19 @@ public void onVideoError() {
// 视频播放完成后,奖励验证回调,rewardVerify:是否有效,rewardAmount:奖励数量,rewardName:奖励名称,code:错误码,msg:错误信息
@Override
public void onRewardVerify(boolean rewardVerify, int rewardAmount, String rewardName, int code, String msg) {
String logString = "verify:" + rewardVerify + " amount:" + rewardAmount +
String logString ="verify:" + rewardVerify + " amount:" + rewardAmount +
" name:" + rewardName + " errorCode:" + code + " errorMsg:" + msg;
Log.e(TAG, "onRewardVerify " + logString);
sendEvent(new AdRewardEvent(posId, rewardVerify, rewardAmount, rewardName, code, msg, customData, userId));
sendEvent(new AdRewardEvent(posId,0, rewardVerify, rewardAmount, rewardName, code, msg, customData, userId));
}

@Override
public void onRewardArrived(boolean isRewardValid, int rewardType, Bundle extraInfo) {
RewardBundleModel rewardBundleModel = new RewardBundleModel(extraInfo);
String logString = "rewardType:"+rewardType+" verify:" + isRewardValid + " amount:" + rewardBundleModel.getRewardAmount() +
" name:" + rewardBundleModel.getRewardName() + " errorCode:" + rewardBundleModel.getServerErrorCode() + " errorMsg:" + rewardBundleModel.getServerErrorMsg();
Log.e(TAG, "onRewardVerify " + logString);
sendEvent(new AdRewardEvent(posId,rewardType, isRewardValid, rewardBundleModel.getRewardAmount(), rewardBundleModel.getRewardName(), rewardBundleModel.getServerErrorCode(), rewardBundleModel.getServerErrorMsg(), customData, userId));
}

@Override
Loading

0 comments on commit ca2d21a

Please sign in to comment.