capacitor-community / admob

Community plugin for using Google AdMob
MIT License
221 stars 69 forks source link

Ads banner disappear with bar code scanner #138

Closed chidav77 closed 2 years ago

chidav77 commented 2 years ago

Describe the bug Really dont know if is a bug but no one has an answer. Hi all, I’m creating a little android app with ads (GitHub - capacitor-community/admob: Community plugin for using Google AdMob) and barcode scanner (GitHub - capacitor-community/barcode-scanner: A fast and efficient (QR) barcode scanner for Capacitor) I’m using capacitor v3. I have a issue that I cannot fix. The test ads is showing correctly but once I call the barcode scanner it disappear. This is ok because the barcode scanner makes webview transparent with the method hideBackground() When I stop the scan and call the showBackgroundMethod(), the ads makes a little flicker and disappear. From the log the ads is loaded but seems not visible.

Using capacitor 3 and angular 13 (basically all latest release available)

To Reproduce Steps to reproduce the behavior:

  1. Show a banner in the app
  2. Open the barcode scanner
  3. Close barcode scanner
  4. Banner disappear

Expected behavior Banner should be visible

Desktop (please complete the following information):

Smartphone (please complete the following information):

distante commented 2 years ago

This would be hard to debug without access to the code. But I would say that the problem is with the position of each android view. Maybe is the ads view below the bar scanner view?

Can you please create a project where we can debug this?

chidav77 commented 2 years ago

Of course I can create a project but I cannot share my ad id. You should use yours. By the way, how can I give the project to you? Should I create a repository on github? Thanks

distante commented 2 years ago

You can just use the ad id that google offers for development. One of these: https://github.com/capacitor-community/admob/blob/966ab602086e0ea1ed95375640ba12b74e0214be/android/src/main/java/com/getcapacitor/community/admob/models/AdOptions.java#L27-L29

And yes, a GitHub repository is the recommended way.

Thank you.

chidav77 commented 2 years ago

As soon as possible I will create a repo for test. Thabk you so much, I didn't know who to ask anymore

chidav77 commented 2 years ago

Hi all, I've created the repository with test app

https://github.com/chidav77/testCapacitorAds (https://github.com/chidav77/testCapacitorAds.git)

Please note: set the app id in android in folder res/strings.xml. I've used mine to reproduce the issue.

The app is very simple. At the open, bottom banner will show. Push the button start scan and the stop scan. You will notice that the bottom banner will flicker and disappear each time you perform this sequence.

Let me know if the repository is ok. Thanks

distante commented 2 years ago

Hi, I took a look, and looks like it is what I said: The Scanner view is "above" the AdMob View

image

Sadly I do not think we can remediate because it would need change the views order and that requires specific per app code.

The only solution I see is to remove the banner :/

chidav77 commented 2 years ago

Thanks. So in this case I cannot use the banner? Is it right? Because removing the banner with the code does nothing. No sorry... Update the post. Is ok if the scanner has no banner, but try to push stop button. The ad will stay under the view. Is the same issue?

distante commented 2 years ago

I just had an idea, how about removing the banner and then calling it again after the scanner is visible?

I think this should append the adview after the scanner view (but I am not 100% sure).

I that doesn't work, then there is no way to do this on the current plugin state.

chidav77 commented 2 years ago

I will try it, but I think does not solve the issue. By the way thanks for the help

chidav77 commented 2 years ago

Just to let you know that remove banner before scan and showbanner after scanner, works. Thanks a lot

distante commented 2 years ago

That is really nice!