I created GADBannerView and register the view controller as GADBannerViewDelegate.
However I cannot make these two methods (adViewWillDismissScreen and adViewDidDismissScreen) call. Only adViewWillPresentScreen is called
I've followed the url http://googleadsdeveloper.blogspot.com/2014/05/google-mobile-ads-sdk-note-on-ad-click.html
on both Simulator and iOS device. The two methods still not get called.
The below is my code.
self.mBannerView1 = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:CGPointMake(0, 100)];
self.mBannerView1.adUnitID = kMyAdUnitID;
self.mBannerView1.rootViewController = self;
self.mBannerView1.delegate = self;
[self.mBannerView1 loadRequest:request];
[self.view addSubview:self.mBannerView1];
Related
I am working on Bottom Banner Ad in table view.It's working fine but client wants to delete the ad when they don't need.So How can I do this???can you give me a suggesstion or code when i try to delete tha ad it's not deleted see my code and image below:
GADRequest *request = [GADRequest request];
self.bannerview = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
self.bannerview.adUnitID = #"ca-app-pub-4719922286387557/3468269154665";
self.bannerview.rootViewController = self;
[self.navigationController.toolbar addSubview:self.bannerview];
[self.bannerview loadRequest:request];
I seem to be unable to hide an Admob banner during my game, using the following method to show;
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
bannerView_.delegate=self;
bannerView_.adUnitID = ADMOB_ID;
bannerView_.rootViewController = self.viewController;
[viewController.view addSubview:bannerView_];
GADRequest *request =[GADRequest request];
[bannerView_ loadRequest:request];
When trying to hide it, even to test it I have hooked it up to a button
- (void)removeBanner{
NSLog(#"should be removing banner");
[bannerView_ setHidden:YES];
[bannerView_ removeFromSuperview];
}
I have tried both of the above options inside removeBanner, however none of them make the banner disappear?
A couple of things to check
Do you call the first function more than once? Put an assert that bannerView_ is not already set. If it were called more than once, you'd only be removing the last one.
Is bannerView_ somehow nil in removeBanner?
edit: probably you should set bannerView_ to nil after you remove it (but I doubt that would matter). Also, you could call setNeedsDisplay on viewController.view (and then displayIfNeeded to force it to happen immediately)
I am working on an iOS app that uses Google Ad SDK. The view controller that is supposed to display the ad is a delegate of GADBannerViewDelegate and GADSwipeableBannerViewDelegate.
The ad comes in just fine most of the time. Sometimes however, AdMob seems to hang and I don't get a response whatsoever in my delegate.
Is there something I have done wrong? Alternatively, is there a way to detect this behavior?
I initialize the ad banner and then in viewWillAppear I reload the ad (assuming it's not already loading). It usually works just fine but again, it sometimes doesn't.
Here is the relevant code:
UPDATE::
I changed the code but to no avail. Here is new code (got rid of previous two methods):
-(void)resetAdView:(UIViewController *)rootViewController {
[self.adMob_ActivityIndicator startAnimating];
if (adBanner_ == nil) {
adBanner_ = [[DFPSwipeableBannerView alloc]
initWithFrame:CGRectMake(30, 365, 300, 150)];
}
[adBanner_ setHidden:YES];
if (isLoaded_) {
GADRequest *request = [GADRequest request];
[adBanner_ loadRequest:request];
[self.scrollView addSubview:adBanner_];
} else {
adBanner_.delegate = self;
adBanner_.rootViewController = rootViewController;
adBanner_.adUnitID = AD_UNIT_ID;
GADRequest *request = [GADRequest request];
[adBanner_ loadRequest:request];
[self.scrollView addSubview:adBanner_];
}
}
My instance variables are :
DFPSwipeableBannerView *adBanner_;
BOOL isLoaded_;
This might be due to lack of ad inventory.
Did you implement the banner view's error catching delegate function?
(void)adView:(DFPBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error
If this delegate method isn't implemented in your code, implement it and log the error object to get a detailed error description.
I ended up just wiping the banner view from the superview and completely re-initializing it and the request. This doesn't solve the problem of the hanging response but now if you switch to a different view and come back to this one, the ad does reload. It's possible that I was simply adding too many views into my scrollview which will not be the case anymore.
-(void)resetAdView:(UIViewController *)rootViewController {
// in reset method
[self.adMob_ActivityIndicator startAnimating];
adBanner_ = nil;
for (UIView *subview in self.scrollView.subviews) {
if (subview.tag == 666) {
// removing banner view from superview
[subview removeFromSuperview];
}
}
// (re) initializing banner view
adBanner_ = [[DFPSwipeableBannerView alloc]
initWithFrame:CGRectMake(30, 365, 300, 150)];
[adBanner_ setHidden:YES];
// setting up and requesting ad
adBanner_.delegate = self;
adBanner_.rootViewController = rootViewController;
adBanner_.adUnitID = AD_UNIT_ID;
GADRequest *request = [GADRequest request];
[adBanner_ loadRequest:request];
adBanner_.tag = 666;
[self.scrollView addSubview:adBanner_];
}
This is the code that I am currently using to show some ads on my device. But it doesn't seem to work as of now. Need some guidance on what could be going wrong here.
self.adBanner = [[GADBannerView alloc]
initWithFrame:CGRectMake(0,468,320,50)];
self.adBanner.adUnitID = #"a153b29f919d822";
self.adBanner.delegate = self;
[self.adBanner setRootViewController:self];
[self.view addSubview:self.adBanner];
//self.adBanner.center = CGPointMake(self.view.center.x, self.adBanner.center.y);
GADRequest *r = [[GADRequest alloc] init];
r.testing = YES;
[self.adBanner loadRequest:r];
Thanks.
If you have recently setup up your account in Google AdMob, it is going to take sometime for the ads to start appearing on the device.
But you can try setting testDevices in your GADRequest. The device Id will be being printed out in your console by the AdMob SDK.
Then add the below code.
r.testDevices = #["test_device_id"];
I want to implement Admob into an app for iPad in landscape mode, I followed step by step tutorial for admob, on adding advertising to the app. I added all the frameworks and requirements given to work correctly.
I can't see the banner. I tried both the simulator and on the device itself. According to the following link it seems that:
"Test ads are not supported on iOS 6 devices; use the simulator instead"
The compilation is correct without issues.
I changed the background of the red banner, and I moved all the views that would hide the banner, but still I couldn't see it. Inside the viewDidLoad method, I have placed it in different positions
From Google admob statistics I see that increase requests, this I don't understand. O___O
The AdMob SDK is the latest.
I appreciate any help.
My code:
bannerView_ = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
self.view.frame.size.height -
GAD_SIZE_728x90.height,
GAD_SIZE_728x90.width,
GAD_SIZE_728x90.height)];
bannerView_.adUnitID = MY_BANNER_UNIT_ID;
bannerView_.delegate = self;
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
[self.view bringSubviewToFront:bannerView_];
bannerView_.backgroundColor= [UIColor redColor];
GADRequest *request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects:
#"6A1E19F-xxxxx-xxxx-xxxxDF38593ECBD" ,
#"9bc75xxxxxxxxxxxxxxx762de7c79fb",
nil];
request.testing = YES;
[bannerView_ loadRequest:request];
try this
request.testDevices = [NSArray arrayWithObjects:#[#"GAD_SIMULATOR_ID"], nil];
[yourbannerview loadRequest:request];
and delete request.test, is disabled now :/