-
Notifications
You must be signed in to change notification settings - Fork 60
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
Google ad click through issue in modal view #30
Comments
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. |
Root view controller -> iAd and Admob show and open browser when clicked After clicking on an iAd however, admob also opens browser when clicked in modal view |
Does the modal view have a view controller managing it? |
Yes, their own subclass of UIViewcontroller |
I've got the same problem. |
A couple of questions:
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. |
Hi, thanks for your reply!
Should it be added in viewDidAppear:?
After some testing I was able to see more side effects: 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? |
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. |
I already use the latest GoogleAds lib. 6.2.1. |
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? |
I think the solution should be here: |
@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. |
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. |
If you can find a reason why it "fails to update" the Make sure that |
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
|
@Fred10932 |
@donrondo |
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 |
Clickthrough on google ads works in root view, but not in modal views behind the root controller, instead I get a warning:
Warning: Attempt to present GADBrowserController: 0x1751e950> on MainViewController: 0x95a6ae0> whose view is not in the window hierarchy!
However, if I click though an iAd first in a modal view, close the browser window, and subsequently a google ad appears, clicking through the Google ad suddenly works.
The text was updated successfully, but these errors were encountered: