firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.68k stars 3.97k forks source link

[firebase_admob] smartBanner with screen rotation works buggy.... #1828

Closed daneed closed 3 years ago

daneed commented 4 years ago

Hi! I don't know how should it work. But I expectation is, If I use smartBanner in my phone as testphone:

  1. i use testBanners. My Phone is Samsung Galaxy S7, with Android 8.
  2. In case portrait Orientation, its height is 50, width is the screen's width. OK.
  3. In case of landscape, height is 32, widht is the screen width. THIS IS OK.
  4. But if I rotate the screen: smartBanner does not refresh.
  5. If I try to request refreshing it manually, like destroy and recreate the banner: sometimes, this works OK. But If I rotate too fast: sometimes two banner appears on the landscape screen, one is with 32 height, it is OK, but sometimes, the 50 height appears there as well. NOT OK. SO??? SOLUTION??? What am I doing wrong? I dont know, whether this should work like this:
    • Banner should be automatically refreshed by Admob, when the screen is rotated.
    • Or: destroy&recreate. About two banner in the screen: if I click to fast in your example, click to show and then destroy and show and destroy: this multiple bannered situation can be reached quite quickly - and, in this case, there is no way anymore to remove both banner!!!

So, only one thing works perfectly: in App initState, create the banner, and in dispose, dispose it. NO any other ad manipulation is possible now.

DaneeD

iapicca commented 4 years ago

Hi @daneed can you please provide your flutter doctor -v , and a reproducible minimal code sample. Thank you

daneed commented 4 years ago

[√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.18362.535], locale en-US) • Flutter version 1.12.13+hotfix.5 at d:\Flutter • Framework revision 27321ebbad (6 weeks ago), 2019-12-10 18:15:01 -0800 • Engine revision 2994f7e1e6 • Dart version 2.7.0

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at C:\Users\daneed\AppData\Local\Android\sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.2 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03) • All Android licenses accepted.

[√] Android Studio (version 3.5) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin version 42.1.1 • Dart plugin version 191.8593 • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[√] Connected device (1 available) • SM G930F • ce12160c78d8a72a05 • android-arm64 • Android 8.0.0 (API 26)


Minimal sample:

  1. I edited your main.dart in your example folder: I changed there size parameter of banner from AdSize.banner to AdSize.smartBanner.
  2. then, run your example.
  3. click on Show Banner: smart sized banner opened as expected. But when I rotate the screen, It would be nice, that It would reloaded to adopt the new screenwidth and height. But It does not, It remains the same.

Tests Details:


What definitely WONT work correctly: Remove banner and show again from code, when screen rotated. Problem: then, the old banner can freeze, so 2 banners will be in the screen, and one can not ever be removed. Repro, with your example (it is the similar): start to click show banner -remove banner very fast. After some time, 2 (or even more!) banner will be on the screen, and only the last can be removed width RemoveBanner.


What would be nice:

daneed commented 4 years ago

I think, that a possible solution can be, that

Maybe, a similar solution also exists for iOS.

moldstadt commented 4 years ago

Is there any plan to fix this, or a workaround for now?

russellwheatley commented 3 years ago

The firebase_admob plugin will be deprecated in April 2021 in favor of Google Mobile Ads SDK for Flutter. Google Mobile Ads SDK for Flutter is a new Flutter plugin that supports more Ads formats than firebase_admob does. Google Mobile Ads SDK for Flutter currently supports loading and displaying banner, interstitial (full-screen), native ads, and rewarded video ads across AdMob and AdManager. It also supports displaying banner and native ads as Widgets as opposed to being overlayed over all app content. We're now recommending projects currently using firebase_admob migrate to Google Mobile Ads SDK for Flutter following the instructions outlined here. Issues with migrating or with using the new package should now be raised over on the Google Mobile Ads SDK for Flutter repository.