Git Product home page Git Product logo

Comments (18)

larsacus avatar larsacus commented on June 27, 2024

Can you explain what you mean by "behind the root controller"? The error you are getting is related to trying to display an ad that is not even in the visible view heirarchy.

from larsadcontroller.

Fred10932 avatar Fred10932 commented on June 27, 2024

Root view controller -> iAd and Admob show and open browser when clicked
Root view controller >> Modal View -> iAd and Admob show but only iAd opens browser when clicked, admob error

After clicking on an iAd however, admob also opens browser when clicked in modal view

from larsadcontroller.

larsacus avatar larsacus commented on June 27, 2024

Does the modal view have a view controller managing it?

from larsadcontroller.

Fred10932 avatar Fred10932 commented on June 27, 2024

Yes, their own subclass of UIViewcontroller

from larsadcontroller.

donrondo avatar donrondo commented on June 27, 2024

I've got the same problem.
Do you already have any solution Fred10932?

from larsadcontroller.

larsacus avatar larsacus commented on June 27, 2024

A couple of questions:

  1. Where is the code located that is adding the ad to your view? viewDidLoad:? viewDidAppear:?
  2. How is your modal view controller being launched? Where in your code is it being called?

I'm asking because it sounds like something is wrong where you are launching the modal view or adding the ad to a view that is not on screen yet.

from larsadcontroller.

donrondo avatar donrondo commented on June 27, 2024

Hi, thanks for your reply!

  1. I add my ad in: viewWillAppear: It is added with:
    [[LARSAdController sharedManager] addAdContainerToViewInViewController:self];

Should it be added in viewDidAppear:?

  1. I've got an UIButton which calls:
    [self presentViewController:modalViewController animated:NO completion:nil]

After some testing I was able to see more side effects:
Google AdMob works if its an ad linking directly to the appstore
Google AdMob doesn't work if it should open fullscreen. But my status bar disappears, so something must be happening.

Google says this must be a problem with the rootViewController property of my GADBannerView. It must set the rootviewcontroller to the one responsible for my modal view. But "addAdContainerToViewInViewController:self];" should do this, or am I wrong?

from larsadcontroller.

larsacus avatar larsacus commented on June 27, 2024

Make sure your GoogleAds library is updated. Just googling what you're describing is bringing up a lot of old issues on google's admob forums that exactly describe the symptoms you're talking about.

from larsadcontroller.

donrondo avatar donrondo commented on June 27, 2024

I already use the latest GoogleAds lib. 6.2.1.

from larsadcontroller.

Fred10932 avatar Fred10932 commented on June 27, 2024

The problem is indeed that GADBrowserController tries to present itself on the parent VC of the modal VC, instead of on the modal VC itself. A simple way to check this is to load ads for the first time in the application on the modal VC instead of on its parent VC. Then everything works correctly.

How can we update the presenting VC of the GADBrowserController to the modal VC when the modal VC is loaded?

from larsadcontroller.

Fred10932 avatar Fred10932 commented on June 27, 2024

I think the solution should be here:
http://googleadsdeveloper.blogspot.be/2012/04/creating-gadbannerview-singleton-in.html

from larsadcontroller.

larsacus avatar larsacus commented on June 27, 2024

@Fred10932, that is the exact way that this class is constructed.

You should always be adding the ad controller to the presenting (visible) view controller and never a "root" view controller unless that root is your most-visible view controller.

from larsadcontroller.

Fred10932 avatar Fred10932 commented on June 27, 2024

Yes, but somehow the setParentViewController method fails to properly update the rootViewController value of Google's bannerView when [[LARSAdController sharedManager] addAdContainerToViewInViewController:self]; is called in the modal VC's viewDidAppear.
Instead GADBrowserController keeps trying to present itself on the first VC in which [[LARSAdController sharedManager] addAdContainerToViewInViewController:self]; was called, in my case the root VC.

from larsadcontroller.

larsacus avatar larsacus commented on June 27, 2024

If you can find a reason why it "fails to update" the rootViewController property, I'd be happy to accept a pull request.

Make sure that self in your above code is actually the view controller you are expecting, and not a different one, which would be causing these issues. You can pass any view controller you need to into that parameter, you don't have to always set self.

from larsadcontroller.

Fred10932 avatar Fred10932 commented on June 27, 2024

It's a bug on Google's end (see https://groups.google.com/group/google-admob-ads-sdk/msg/c4a7da95d18a758d?dmode=source&output=gplain&noredirect&pli=1), which should be resolved in the next SDK release.

Meanwhile, the recommended workaround by Google is the following (see link posted 4msg ago):

Forwarding Delegate Notifications
An important note is that the AdMob SDK doesnโ€™t let you change delegates after a request has been made. This means that if you switch view controllers after making an ad request, all GADBannerViewDelegate notifications will continue to be sent to the initial delegate (first view controller). A workaround for this is to make GADMasterViewController conform to the GADBannerViewDelegate protocol, then forward any notifications it receives to the correct view controller. This is the reasoning behind always setting currentDelegate_ in resetAdView:. Forwarding the notification takes minimal code. Here is an example of forwarding the adViewDidReceiveAd: notification:

  • (void)adViewDidReceiveAd:(GADBannerView *)view {
    // Make sure that the delegate actually responds to this notification
    if ) {
    [currentDelegate_ adViewDidReceiveAd:view];
    }
    }
    With these easy steps, your application is set up to use a singleton GADBannerView. If you have any questions about this topic or the SDK in general, feel free to post them in our forum or come join us in our upcoming office hours.

from larsadcontroller.

donrondo avatar donrondo commented on June 27, 2024

@Fred10932
Have you tried implementing this solution? Is it working for you?

from larsadcontroller.

Fred10932 avatar Fred10932 commented on June 27, 2024

@donrondo
I went another route: working with a nav controller now (no issues anymore with pushed view controllers).

from larsadcontroller.

larsacus avatar larsacus commented on June 27, 2024

I'm still trying to wrapt head around why this isn't working. Based on the snippet above from the google thread, they are assuming that each view controller is conforming to their delegate protocol. This is not the case with this project since LARSAdController's adapters are acting as the delegate, which never changes, so it seems to not apply.

from larsadcontroller.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.