JKBaseLib/README.md

76 lines
2.2 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 广告模块集成指南
#### 版本 1.0.0
#### 项目gradle
```java
maven {
url "http://124.221.136.193:3000/app-lib/JKBaseLib/raw/master/maven"
allowInsecureProtocol = true // 允许HTTP
metadataSources {
artifact() // 强制校验POM文件
}
}
```
#### 模块的gradle
```java
implementation ('com.your.group:lib-name:1.0.0@aar') {
transitive = true // 确保嵌套依赖被加载
}
```
### 基础配置(必填项)
```java
new AdApp.Builder(this, Constants.APP_NAME, getChannel(), getAppSplash())
.addSlot(AD_APPID, "app_id") // APPID
.addSlot(AD_CSJID, "csj_id") // CSJID
.addSlot(AD_CODE_SPLASH, "splash_id") // 添加横幅广告位
.addSlot(AD_CODE_REWARD, "reward_id") // 激励视频广告位
.addSlot(AD_CODE_FEED1, "feed1_id") // 信息流1广告位
.addSlot(AD_CODE_FEED2, "feed2_id") // 信息流2广告位
.addSlot(AD_CODE_FEED3, "feed3_id") // 信息流3广告位
.addSlot(AD_CODE_BANNER, "banner_id") // banner广告位
.addSlot(AD_CODE_Draw, "draw_id") // draw广告位
.initialize();
```
| 参数 | 类型 | 必填 | 说明 |
|-----------|---------|------|----------|
| context | Context | ✓ | 应用上下文 |
| APP_NAME | String | ✓ | 应用名称 |
| CHANNEL | String | ✓ | 渠道 |
| AppSplash | int | ✓ | 启动页id |
| APPID | String | ✕ | appid |
| CSJID | String | ✕ | csjid |
| AD_CODE_* | String | ✕ | 各类型广告位id |
### 调试模式
```java
// 开发阶段开启(正式环境需关闭)
- LogAd.setDebug(true);
```
### 最佳实践
- 初始化时机在Application.onCreate()中完成初始化
- 隐私合规‌:确保用户已同意隐私政策
- 版本兼容最低支持Android 7.0(API 24)
### 广告开关初始化失败监听
```java
// 重新请求广告开关
ADStateUtils.setSwitchRequestListener(new ADStateUtils.SwitchRequestListener() {
@Override
public void onSwitchRequestChanged() {
AdUtils.getAdvFlag();
}
});
```
### 注意事项
#### ⚠️ 正式发布前确认:
- 调试日志已关闭
- 所有广告位ID已测试通过
- 符合广告平台政策要求