插屏广告

插屏广告

  • 类型说明: 插屏广告是移动广告的一种常见形式,在应用开流程中弹出,当应用展示插页式广告时,用户可以选择点按广告,访问其目标网址,也可以将其关闭,返回应用。

插屏广告调用

/// show interstitial ad
  static void showInterstitialAd(String adId,
      {AdCallback? onAdLoad,
      AdCallback? onAdShow,
      AdCallback? onAdClick,
      AdCallback? onAdClose,
      AdCallback? onAdDetailClose,
      AdCallback? onError}) {
    _methodChannel.invokeMethod(
        "showInterstitialAd", {"_channelId": _channelId, "adId": adId});

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

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

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

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

        case "interstitialAdDetailDidClose":
          onAdDetailClose?.call("interstitialAdDetailDidClose", "");
          break;

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

插屏广告回调说明

//插屏广告数据加载成功回调
interstitialAdDidLoad

//插屏广告错误回调
interstitialAdError

//插屏广告展示
interstitialAdDidPresentScreen

//插屏广告点击
interstitialAdDidClick

//插屏广告关闭
interstitialAdDidClose

//插屏广告详情页关闭
interstitialAdDetailDidClose

代码调用展示

ZjsdkFlutter.showInterstitialAd(
    "J9666281550", // 广告位ID
    onAdLoad: (String id,String msg) {
        print("InterstitialAd onAdLoad");
    },
    onAdShow: (String id,String msg) {
        print("InterstitialAd onAdShow");
    },
    onAdClick: (String id,String msg) {
        print("InterstitialAd onAdClick");
    },
    onAdClose: (String id,String msg) {
        print("InterstitialAd onAdClose");
    },
    onAdDetailClose: (String id,String msg){
        print("InterstitialAd onAdDetailClose");
    },
    onError: (String id, String msg) {
        print("InterstitialAd onError = "+(msg));
    },
);