如何在 flutter 中等待带有等待对话框的插页式广告
How to wait interstitial ad with waiting dialog in flutter
Here 是一篇文章,其中指出您不应该使用插页式广告让用户感到惊讶。
我有这样的代码来延迟广告出现:
void _onLoading() {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(32.0))),
contentPadding: EdgeInsets.only(top: 10.0),
content: Container(
margin: const EdgeInsets.all(10.0),
child: new Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new CircularProgressIndicator(),
SizedBox(width: 16.0),
new Text("Please wait.."),
],
)),
));
new Future.delayed(new Duration(seconds: 3), () {
Navigator.pop(context); //pop dialog
createInterstitialAd()
..load()
..show();
});}
但该代码仅等待 3 秒,并且在出现时不依赖于插页式广告。在这种情况下,如果 3 秒后连接仍然很慢,它将保持静音。在插页式广告真正出现之前,我该如何处理。
谢谢
我在我的代码中使用了它:
InterstitialAd myInterstitialAd = InterstitialAd(
adUnitId: <youradUnitId>,
targetingInfo: MobileAdTargetingInfo(
childDirected: true,
nonPersonalizedAds: true,
),
listener: (event) {
if (event == MobileAdEvent.opened || event == MobileAdEvent.failedToLoad) {
<go to another page>
}
});
Here 是一篇文章,其中指出您不应该使用插页式广告让用户感到惊讶。
我有这样的代码来延迟广告出现:
void _onLoading() {
showDialog(
context: context,
barrierDismissible: false,
builder: (context) => AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(32.0))),
contentPadding: EdgeInsets.only(top: 10.0),
content: Container(
margin: const EdgeInsets.all(10.0),
child: new Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new CircularProgressIndicator(),
SizedBox(width: 16.0),
new Text("Please wait.."),
],
)),
));
new Future.delayed(new Duration(seconds: 3), () {
Navigator.pop(context); //pop dialog
createInterstitialAd()
..load()
..show();
});}
但该代码仅等待 3 秒,并且在出现时不依赖于插页式广告。在这种情况下,如果 3 秒后连接仍然很慢,它将保持静音。在插页式广告真正出现之前,我该如何处理。 谢谢
我在我的代码中使用了它:
InterstitialAd myInterstitialAd = InterstitialAd(
adUnitId: <youradUnitId>,
targetingInfo: MobileAdTargetingInfo(
childDirected: true,
nonPersonalizedAds: true,
),
listener: (event) {
if (event == MobileAdEvent.opened || event == MobileAdEvent.failedToLoad) {
<go to another page>
}
});