在执行 launchURL 之前加载我的广告。
buttonactionL: () async{
await StartApp.showInterstitialAd();
String url = "https://google.com";
_launchURL(url);
},
调用showAds
方法并在完成onAdClosed
和onAdFailedToLoad
执行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();
}