Skip to main content

Flutter - 插页广告

概览


本篇将说明如何透过 Vpon Flutter Plugin 串接插页广告,您也可以在 pub.dev 查看我们的串接文件与 Plugin 讯息。

插页广告串接

宣告 Interstitial Ad 物件


InterstitialAd? _interstitialAd;

请求插页广告


 void _loadInterstitialAd() {
    VponAdRequest request = VponAdRequest();

    InterstitialAd.load(
        licenseKey: 'Your license key',
        request: request,
        adLoadCallback: InterstitialAdLoadCallback(
            onAdLoaded: (InterstitialAd ad) {
                _interstitialAd = ad;
            },
            onAdFailedToLoad: (Map error) {
                _interstitialAd = null;
            },
            onAdImpression: (InterstitialAd ad) {
                // handle impression
            },
            onAdClicked: (InterstitialAd ad) {
                // handle click
            },
            onAdWillDismissFullScreenContent: (InterstitialAd ad) {
                // handle callback
            },
            onAdDismissedFullScreenContent: (InterstitialAd ad) {
                // handle callback
            },
            onAdWillShowFullScreenContent: (InterstitialAd ad) {
                // handle callback
            },
        ),
    );
  }

Note: 您可以透过实作 InterstitialAdLoadCallback 来监听广告事件。

展示插页广告


_interstitialAd.show();