Comments (18)
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.
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.
Does the modal view have a view controller managing it?
from larsadcontroller.
Yes, their own subclass of UIViewcontroller
from larsadcontroller.
I've got the same problem.
Do you already have any solution Fred10932?
from larsadcontroller.
A couple of questions:
- Where is the code located that is adding the ad to your view?
viewDidLoad:
?viewDidAppear:
? - 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.
Hi, thanks for your reply!
- I add my ad in: viewWillAppear: It is added with:
[[LARSAdController sharedManager] addAdContainerToViewInViewController:self];
Should it be added in viewDidAppear:?
- 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.
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.
I already use the latest GoogleAds lib. 6.2.1.
from larsadcontroller.
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.
I think the solution should be here:
http://googleadsdeveloper.blogspot.be/2012/04/creating-gadbannerview-singleton-in.html
from larsadcontroller.
@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.
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.
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.
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.
@Fred10932
Have you tried implementing this solution? Is it working for you?
from larsadcontroller.
@donrondo
I went another route: working with a nav controller now (no issues anymore with pushed view controllers).
from larsadcontroller.
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)
- google ads set to appear at top, which are not full-screen width, are placed in top left, not top center. HOT 9
- Blank Presenting View when Added as Subview iOS 8 HOT 2
- Banner position in runtime HOT 5
- GADBannerViewDelegate.h not found - first issue HOT 7
- GADBannerViewDelegate.h not found HOT 9
- Notification on bannerViewActionShouldBegin and bannerViewActionDidFinish HOT 3
- apps orientation settings not inherited? HOT 1
- error "Include of non-modular header inside framework module " HOT 5
- Ads in a list view? HOT 1
- 'interfaceOrientation' is deprecated: first deprecated in iOS 8.0 HOT 1
- Having trouble hiding AdBanner when no ad is visible HOT 11
- Build Error: 'GADBannerViewDelegate.h" not found HOT 11
- Delete HOT 2
- Global Disable Without Subclassing HOT 2
- iPad ContainerView Height Wrong? HOT 1
- 3.1.1 Causing freezing with Google Mobile Ads 7.5.2
- originalContentView with iAds
- In Landscape mode, when using Split View multitasking, ad container is wrong. (found fix!) HOT 3
- Carthage
- Portrait ads do not display correctly on iPad Pro 12.9" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from larsadcontroller.