Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Banner view content not displayed after back navigation #10

Open
Darkos-den opened this issue Apr 10, 2022 · 9 comments
Open

Banner view content not displayed after back navigation #10

Darkos-den opened this issue Apr 10, 2022 · 9 comments

Comments

@Darkos-den
Copy link

Steps for reproducing:

  • open screen with appodeal banner view
  • push new screen
  • tap back

Expected result: banner view content displayed normally;
Actual result: banner view content not displayed;

@da2gl
Copy link
Collaborator

da2gl commented Apr 21, 2022

@Darkos-den Hello!
Thanks for your issue, we started to investigate this behavior.

@da2gl
Copy link
Collaborator

da2gl commented Jun 2, 2022

@Darkos-den Hi! Can you attach logs from Appodeal SDK?

@marcos93net
Copy link

Same problem.. Any solution?

@Darkos-den
Copy link
Author

Darkos-den commented Jun 14, 2022

@Darkos-den Hi! Can you attach logs from Appodeal SDK?

@da2gl When returning from another screen, the library does not generate any logs. As far as I understand, the library considers that the banner has already been initialized and because of this it is not rendered.

@Darkos-den
Copy link
Author

Same problem.. Any solution?

@marcos93net I made a small hack to solve this issue - every time I return from another screen, I change the state for some object that I use to draw the banner.

Page widget:

ValueListenableBuilder<int>(
                    valueListenable: AdUtil().invalidateBannerAd,
                    builder: (_, value, ___) {
                      if (value % 2 == 0) {
                        return Container();
                      }
                      return AppodealBanner(adSize: AppodealBannerSize.BANNER);
                    },
                  )

AdUtil:

final ValueNotifier<int> invalidateBannerAd = ValueNotifier<int>(1);

  void invalidateBanner() async {
    await Future.delayed(Duration(milliseconds: 50)).then((value) {
      if (invalidateBannerAd.value > 1000) {
        invalidateBannerAd.value = 1;
      } else {
        invalidateBannerAd.value = invalidateBannerAd.value + 1;
      }
    });
    await Future.delayed(Duration(milliseconds: 50)).then((value) {
      if (invalidateBannerAd.value > 1000) {
        invalidateBannerAd.value = 1;
      } else {
        invalidateBannerAd.value = invalidateBannerAd.value + 1;
      }
    });
  }

App widget:

MaterialApp(
          navigatorObservers: [
            AppFirebaseAnalyticsObserver(
              onPop: () {
                AdUtil().invalidateBanner();
              }
            ),
          ],
        )

This is a rather dirty solution, but so far I have not come up with anything better.

@phamanhminh1208
Copy link

Is there any update. I'm using version 3.0.0 and this issue is still alive

@da2gl
Copy link
Collaborator

da2gl commented Jan 24, 2023

@phamanhminh1208 @Darkos-den Hello!
We're back to the banner view issue, but we cannot reproduce this behavior.
If you could attach a project or snippets of the display and initialization code, it would help us fix the problem.
And tell me, do you show the banner after initialization or before it?
Thanks.

@da2gl da2gl closed this as not planned Won't fix, can't repro, duplicate, stale Feb 15, 2023
@ihenvyr
Copy link

ihenvyr commented Oct 26, 2023

Steps for reproducing:

  • open screen with appodeal banner view
  • push new screen
  • tap back

Expected result: banner view content displayed normally; Actual result: banner view content not displayed;

Hello, same problem for me.

@phamanhminh1208 @Darkos-den Hello! We're back to the banner view issue, but we cannot reproduce this behavior. If you could attach a project or snippets of the display and initialization code, it would help us fix the problem. And tell me, do you show the banner after initialization or before it? Thanks.

I hope the sample screencast and code snippet will help.

banner_view_bug

Here's the sample code to reproduce the issue.

class FirstScreen extends StatelessWidget {
  const FirstScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('First Screen'),
      ),
      body: Center(
        child: ElevatedButton(
          child: const Text('Second Screen'),
          onPressed: () {
            Navigator.push(
              context,
              MaterialPageRoute(builder: (context) => const SecondScreen()),
            );
          },
        ),
      ),
      bottomNavigationBar: const Column(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.end,
        children: [
          Center(
            child: AppodealBanner(
              adSize: AppodealBannerSize.BANNER,
            ),
          ),
        ],
      ),
    );
  }
}

class SecondScreen extends StatelessWidget {
  const SecondScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Second Screen'),
      ),
      body: Center(
        child: ElevatedButton(
          child: const Text('Back to First Screen'),
          onPressed: () {
            Navigator.pop(context);
          },
        ),
      ),
      bottomNavigationBar: const Column(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.end,
        children: [
          Center(
            child: AppodealBanner(
              adSize: AppodealBannerSize.BANNER,
            ),
          ),
        ],
      ),
    );
  }
}

@da2gl da2gl reopened this Oct 27, 2023
@algaren
Copy link

algaren commented Aug 7, 2024

Used @Darkos-den as inspiration. (dirty solution--)

Then you just call AdAdaptiveBanner()

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:stack_appodeal_flutter/stack_appodeal_flutter.dart';

class AdAdaptiveBanner extends StatefulWidget {
  const AdAdaptiveBanner({super.key});

  @override
  AdAdaptiveBannerState createState() => AdAdaptiveBannerState();
}

class AdAdaptiveBannerState extends State<AdAdaptiveBanner> {
  late int counter;

  @override
  void initState() {
    super.initState();
    counterBannerAd.value = counterBannerAd.value + 1;
    counter = counterBannerAd.value;
  }

  @override
  void dispose() {
    super.dispose();
    refreshBanner();
  }

  @override
  Widget build(BuildContext context) {
    return ValueListenableBuilder<int>(
      valueListenable: counterBannerAd,
      builder: (_, value, ___) {
        if (value != counter) {
          return const SizedBox();
        }
        return const AppodealBanner(adSize: AppodealBannerSize.BANNER);
      },
    );
  }
}

final ValueNotifier<int> counterBannerAd = ValueNotifier<int>(0);

void refreshBanner() async {
  await Future.delayed(const Duration(milliseconds: 50)).then((value) {
    counterBannerAd.value = counterBannerAd.value + 1;
  });
  await Future.delayed(const Duration(milliseconds: 50)).then((value) {
    counterBannerAd.value = counterBannerAd.value - 2;
  });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants