Search code examples
flutterflutter-dependenciesflutter-webflutter-animation

There is any method to show appopenAd while app move background to resumed


When we show Interstitial ads, App open ad is also displayed each time. it means display twice ads 1 interstitial and another one is App open. some times it going to in infinite loop, App open ads not close.


Solution

  • The problem is interstitial popping up is considered as native android element and it causes flutter app to change its lifecycle to inactive and after you close the native view interstitial the flutter app come back to life and it changes its lifecycle to resumed so your code calls the show app open ads immediately.

    As a work around for this ill suggest you to use this plugin : flutter_fgbg https://pub.dev/packages/flutter_fgbg

    and then you can listen to the app if its on background or foreground and show the app open ad when app on foreground

    late StreamSubscription subscription;

    @override

    void initState() {

    subscription = FGBGEvents.stream.listen((event) {

    print(event);

    if (event == FGBGType.foreground) {

    MobileAds.instance.initialize();

    load(); }

    });}