我正在使用这个包:https ://pub.dev/packages/firebase_admob
一切都已正确设置,并且显示了正常的横幅。我的问题只出现在插页式广告中:
import 'package:firebase_admob/firebase_admob.dart';
BannerAd myBanner = BannerAd(
adUnitId: BannerAd.testAdUnitId,
size: AdSize.smartBanner,
listener: (MobileAdEvent event) {
print("BannerAd event is $event");
},
);
InterstitialAd myInterstitial = InterstitialAd(
adUnitId: 'ca-app-pub-MYID',
listener: (MobileAdEvent event) {
print("InterstitialAd event is $event");
},
);
class Ads {
static showBanner() {
myBanner
// typically this happens well before the ad is shown
..load()
..show(
// Positions the banner ad 60 pixels from the bottom of the screen
anchorOffset: 0.0,
// Positions the banner ad 10 pixels from the center of the screen to the right
horizontalCenterOffset: 0.0,
// Banner Position
anchorType: AnchorType.bottom,
);
}
static showInterstitial() {
myInterstitial
..load()
..show(
anchorType: AnchorType.bottom,
anchorOffset: 0.0,
horizontalCenterOffset: 0.0,
);
}
}
final Ads ads = Ads();
为了展示它,我这样做了:Ads.showInterstitial();
但它从未展示过。
如果我尝试再次调用它,错误会破坏应用程序。
我不在Statefull
我的应用上使用小部件