0

在执行 launchURL 之前加载我的广告。

buttonactionL: () async{
                await StartApp.showInterstitialAd();
                String url = "https://google.com";
                _launchURL(url);
              },
4

1 回答 1

0

调用showAds方法并在完成onAdClosedonAdFailedToLoad执行launchURl操作时:

  void showAds() {

    _interstitialAd = InterstitialAd(
      adUnitId: AdHelper.interstitialAdUnitId,
      request: AdRequest(),
      listener: AdListener(onAdLoaded: (ad) {
        print("Ad Loaded");
        showAds();
      }, onAdClosed: (ad) {
        print("Closed Ad");
      }, onAdOpened: (ad) {
        print("Opened Ad");
      }, onAdFailedToLoad: (ad, error) {
        print("Failed to load Ad $error");
      }),
    );
    _interstitialAd.load();
  }
于 2021-07-08T17:54:20.680 回答