Skip to content

开屏(Splash)广告的对接及示例

1. 导入 SplashController 模块

typescript
import { SplashController } from "@zmide/react-native-gromore";

2. 使用 SplashController 对象的 show 方法

TIP

必须为 SplashController 传入相应的 slotId

示例:

TouchableNativeFeedback 组件为容器,点击触发开屏广告。

typescript
<TouchableNativeFeedback
  onPress={async () => {
    await SplashController?.show({
      slotId: codes.splash_code,
      onAdLoadSuccess() {
        console.log('Splash onAdLoadSuccess');
      },
      onAdLoadFail(error) {
        console.log('Splash onAdLoadFail', error);
      },
      onAdDidShow() {
        console.log('Splash onAdDidShow');
      },
      onAdViewControllerDidClose() {
        console.log('Splash onAdViewControllerDidClose');
      },
    });
  }}>
  <View>
    <Text>Start Splash</Text>
  </View>
</TouchableNativeFeedback>

SplashController 事件列表如下:

事件名称描述仅限iOS
onAdLoadSuccess广告加载成功
onAdLoadFail广告加载失败
onAdWillShow广告即将展示
onAdDidClick广告被点击
onAdDidShowFailed广告展示失败
onAdDidClose广告被关闭
onAdDidShow广告展示成功
onAdRenderFail广告渲染失败
onAdRenderSuccess广告渲染成功
onAdViewControllerDidClose广告视图控制器关闭
onAdDidCloseOtherController关闭其他广告控制器
onAdVideoAdDidPlayFinish视频广告播放完成