DeepAdx Flutter SDK
DeepAdx 聚合广告 Flutter 插件,封装 deepadx-android 与 deepadx-ios 原生聚合 SDK,提供统一的 Dart API。
支持广告形态:
| 形态 | Dart API | 说明 |
|---|---|---|
| 开屏 | DeepAdxSplashView / DeepAdxSplash |
PlatformView 全屏容器承载 |
| 插屏 | DeepAdxInterstitial |
无视图,全屏展示 |
| 激励视频 | DeepAdxRewardVideo |
无视图,全屏展示,含奖励回调 |
| 原生信息流 | DeepAdxNativeExpressView / DeepAdxNativeExpress |
PlatformView 容器承载 |
| 横幅 | DeepAdxBannerView / DeepAdxBanner |
PlatformView 容器承载 |
完整对接文档见 example/INTEGRATION.md (集成配置、各广告形态完整代码、事件回调表、错误码、平台差异、FAQ)
安装
dependencies:
deepadx_sdk: ^1.0.2
flutter pub add deepadx_sdk
快速接入
1. 初始化
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await DeepAdxFlutterSdk.init(
androidAppId: '你的 Android AppID',
iosAppId: '你的 iOS AppID',
// appId: '通用 AppID', // 双端相同时可只传 appId
);
await DeepAdxFlutterSdk.setDebug(true, logLevel: DeepAdxLogLevel.simple);
runApp(const MyApp());
}
2. 开屏
bool _showSplash = true;
Stack(children: [
YourHomePage(),
if (_showSplash)
Positioned.fill(
child: DeepAdxSplashView(
ad: DeepAdxSplash(
placementId: '开屏广告位ID',
onSucceed: () => print('加载成功'),
onFailed: (e) => setState(() => _showSplash = false),
onClose: () => setState(() => _showSplash = false),
),
),
),
]);
3. 插屏 / 激励视频
final ad = DeepAdxInterstitial(
placementId: '插屏广告位ID',
onSucceed: () => print('加载成功'),
onFailed: (e) => print('失败 $e'),
onClose: () => ad.destroy(),
);
await ad.loadAndShow();
final ad = DeepAdxRewardVideo(
placementId: '激励广告位ID',
userId: 'user_123',
rewardName: '金币',
rewardAmount: 100,
onReward: () => /* 发放奖励 */,
onFailed: (e) => print('失败 $e'),
);
await ad.loadAndShow();
4. 横幅 / 原生信息流
DeepAdxBannerView(
ad: DeepAdxBanner(
placementId: '横幅广告位ID',
onSucceed: () => print('加载成功'),
onFailed: (e) => print('失败 $e'),
),
width: 320,
height: 50,
)
DeepAdxNativeExpressView(
ad: DeepAdxNativeExpress(
placementId: '原生广告位ID',
onSucceed: () => print('加载成功'),
onRenderSuccess: () => print('渲染成功'),
onFailed: (e) => print('失败 $e'),
),
width: 350,
)
原生依赖配置
插件已自动引入核心 SDK,如需接入渠道适配器(穿山甲、优量汇、百度、快手等), 还需在宿主工程中追加对应依赖。
Android
在宿主 App 的 build.gradle 中添加渠道适配器及成对的三方 SDK:
repositories {
maven { url "https://maven.deepadx.com/repository/maven-releases/" }
maven { url 'https://artifact.bytedance.com/repository/pangle' }
}
dependencies {
// 每个适配器必须与对应三方 SDK 成对引入
// 穿山甲(国内)
implementation "com.deepadx.sdk:deepadx-adapter-csj:2.1.7"
implementation "com.pangle_beta.cn:mediation-sdk:7.4.1.4"
// 优量汇 GDT
implementation "com.deepadx.sdk:deepadx-adapter-gdt:2.1.7"
implementation "com.deepadx.thirdparty:gdt-union-normal:4.640.1510"
// 百度
implementation "com.deepadx.sdk:deepadx-adapter-bd:2.1.7"
implementation "com.deepadx.thirdparty:baidu-mobads-sdk:9.432"
// 快手
implementation "com.deepadx.sdk:deepadx-adapter-ks:2.1.7"
implementation "com.deepadx.thirdparty:kssdk-ad:5.1.20.1"
// Google AdMob GG
implementation "com.deepadx.sdk:deepadx-adapter-gg:2.1.7"
implementation "com.google.android.gms:play-services-ads:24.9.0"
// 穿山甲海外版(与 csj 二选一)
implementation "com.deepadx.sdk:deepadx-adapter-pag:2.1.7"
implementation "com.pangle.global:ads-sdk:6.5.1.2"
}
按实际渠道删减未用行。csj 与 pag 二选一(字节系国内/海外不可共存)。
iOS
在宿主 Podfile 中追加渠道 subspec:
target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
pod 'DeepAdxSDK', '2.0.5', :subspecs => ['Core', 'CSJ', 'GDT', 'KS', 'BD']
end
可用 subspec:
Core、CSJ(穿山甲)、GDT(优量汇)、KS(快手)、BD(百度)、GG(Google AdMob)、PAG(穿山甲海外)。
事件语义(双端对齐)
| 事件 | 说明 |
|---|---|
onAdSucceed / onAdFailed |
加载成功/失败(DeepAdxError.code 为 2000–2017 聚合层错误码) |
onAdExposure / onAdClicked |
曝光 / 点击 |
onAdClose |
广告关闭;开屏跳过/倒计时结束在双端均以 onAdClose 收尾 |
onAdSkip / onAdCountdownToZero |
仅 iOS 透出,作为 onAdClose 前的补充信息 |
激励:onVideoCached / onVideoComplete / onVideoSkip / onAdReward |
视频缓存完成/播放完成/跳过/奖励生效 |
激励:onRewardServerInf |
服务端奖励回调(仅 Android 穿山甲/百度) |
原生:onRenderSuccess / onRenderFailed |
模板渲染成功/失败 |
版本
| 组件 | 版本 |
|---|---|
| deepadx_sdk | 1.0.2 |
| deepadx-android | 2.1.7 |
| DeepAdxSDK (iOS) | 2.0.5 |
Libraries
- deepadx_sdk
- DeepAdx Flutter 聚合广告 SDK。