开屏广告

开屏广告

  • 类型说明: 开屏广告主要是 APP 启动时展示的全屏广告视图,开发只要按照接入标准就能够展示设计好的视图。

开屏广告调用

static void showSplashAd(String adId, int fetchDelay,
      {AdCallback? onAdLoad,
      AdCallback? onAdShow,
      AdCallback? onAdClick,
      AdCallback? onCountdownEnd,
      AdCallback? onAdClose,
      AdCallback? onError}) {
    _methodChannel.invokeMethod("showSplashAd",
        {"_channelId": _channelId, "adId": adId, "fetchDelay": fetchDelay});

    EventChannel eventChannel =
        EventChannel("com.zjsdk.adsdk/event_$_channelId");
    eventChannel.receiveBroadcastStream().listen((event) {
      switch (event["event"]) {
        case "splashAdDidLoad":
          onAdLoad?.call("splashAdDidLoad", "");
          break;

        case "splashAdSuccessPresentScreen":
          onAdShow?.call("splashAdSuccessPresentScreen", "");
          break;

        case "splashAdClicked":
          onAdClick?.call("splashAdClicked", "");
          break;

        case "splashAdCountdownEnd":
          onCountdownEnd?.call("splashAdCountdownEnd", "");
          break;

        case "splashAdClosed":
          onAdClose?.call("splashAdClosed", "");
          break;

        case "splashAdError":
          onError?.call("splashAdError", event["error"]);
          break;
      }
    });
  }

开屏广告回调说明

  • 通过回调中的event获取
//开屏广告素材加载成功
splashAdDidLoad

//开屏广告成功展示
splashAdSuccessPresentScreen

//开屏广告点击回调
splashAdClicked

//开屏广告关闭回调
splashAdClosed

//应用进入后台时回调 详解: 当点击下载应用时会调用系统程序打开,应用切换到后台
 splashAdApplicationWillEnterBackground

//开屏广告倒记时结束
splashAdCountdownEnd;

//开屏广告错误
splashAdError;

代码调用展示

ZjsdkFlutter.showSplashAd(
    "J5621495755", // 广告位ID
    5, // 拉取广告超时时间
    onAdLoad: (String id, String msg) {
        print("SplashAd onAdLoad");
    },
    onAdShow: (String id, String msg) {
        print("SplashAd onAdShow");
    },
    onAdClick: (String id, String msg) {
        print("SplashAd onAdClick");
    },
    onCountdownEnd: (String id, String msg) {
        print("SplashAd onVideoComplete");
    },
    onAdClose: (String id, String msg) {
        print("SplashAd onAdClose");
    },
    onError: (String id, String msg) {
        print("SplashAd onError = " + (msg));
    },
);