Skip to content

Commit

Permalink
✨ 预加载开屏
Browse files Browse the repository at this point in the history
  • Loading branch information
BytesZero committed Mar 31, 2024
1 parent a422864 commit 4611183
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Binary file modified docs/public/imgs/view/video_splash.mp4
Binary file not shown.
40 changes: 39 additions & 1 deletion docs/start/guide/gromore/splash.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { normalizeImagePath } from 'rspress/runtime';

- 半开屏配置和设计计算略有难度,可参考示例项目中的配置
- [参考官方文档](https://www.csjplatform.com/union/media/union/download/detail?id=142&docId=27615&osType=android)
- 开屏预加载功能,仅 Pro 版本支持
- Pro 版客户,如有问题随时联系我,提供配置指导

:::
Expand All @@ -27,7 +28,7 @@ FlutterGromoreAds.showSplashAd(

## 半开屏

```dart title="example/pages/splash_page.dart"
```dart dart {5} title="example/pages/splash_page.dart"
/// [posId] 广告位 id
/// [logo] 底部 logo 资源名称
FlutterGromoreAds.showSplashAd(
Expand All @@ -38,3 +39,40 @@ FlutterGromoreAds.showSplashAd(

> Logo 图配置请参考示例
## 预加载开屏(Pro)

仅 Pro 版本支持开屏广告的预加载,预加载会增加更好的体验

```dart dart {6} title="example/pages/splash_page.dart"
/// [posId] 广告位 id
/// [preload] 是否预加载,不展示
/// (第 2 次调用则会展示第1次预加载的广告)
FlutterGromoreAds.showSplashAd(
posId,
preload: true,
);
```

## 展示预加载(Pro)

要在广告事件监听 `AdEventAction.onAdLoaded` 中再次调用展示开屏方法,需要设置预加载 `preload: true`

```dart dart {5-15} title="example/pages/splash_page.dart"
/// 设置广告监听
Future<void> setAdEvent() async {
FlutterGromoreAds.onEventListener((event) {
debugPrint('onEventListener adId:${event.adId} action:${event.action}');
if (event.action == AdEventAction.onAdLoaded) {
// 广告加载成功
// 判断是开屏代码位 id,如果是预加载则展示, preload: true 一定要传
if (event.adId == AdsConfig.splashId) {
FlutterGromoreAds.showSplashAd(
AdsConfig.splashId,
logo: AdsConfig.logo,
preload: true,
);
}
}
});
```

0 comments on commit 4611183

Please sign in to comment.