I successfully added an iAd banner to my game (which plays in landscape mode), however I'm lost as to how to handle the ad being pushed. When the banner ad is pushed the game continues in the background and the player dies. Is there code to pause the game when the banner ad is clicked and resume when the ad goes away? Also when the banner ad is clicked, the ad shows up in portrait mode. Can I keep the ad in landscape mode so it is in sync with my landscape game? I'm a newbie please bear with me thanks!
You need to become the banner's delegate.
In your header file, change the #interface line by adding <ADBannerViewDelegate>, or add , ADBannerViewDelegate inside the angle brackets if you already have some. In the code where you create your banner ad, add a line like this:
self.bannerAdView.delegate = self;
Or if you're using Storyboards or IB, connect the banner ad's delegate outlet to your controller.
Once that's all done, implement these methods:
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
if (!willLeave)
{
// pause your game here
}
return YES;
}
- (void)bannerViewActionDidFinish:(ADBannerView *)banner
{
// unpause your game
}
If your entire game is landscape, I'd recommend that you set your app to only support landscape orientations. This is done in your target settings as described in this technical note. I think that this will restrict the ads to landscape, but I've only tested that on an iPad, so it may be different on the iPhone.
Related
When an iAd banner is clicked, and the interactive ad doesn't leave the app, are ads still received by the app while the full screen ad is displayed? Or is receiving new ads suspended at this time?
It doesn't say either way in Apple's docs.
I ask because I want to give the app every chance to optimize the CTR (click-through rate), so I'm wondering if I should stop ads manually like this:
- (BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner
willLeaveApplication:(BOOL)willLeave {
if(!willLeave) {
[self destroyAdBanner]; // to stop receiving new ads
}
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self createAdBanner]; // start receiving new ads again if not already
}
What is the official approach? An Apple reference would be greatly appreciated.
There is no official documentation that I can find, but from repeated trials after an ad banner is clicked and the full-screen ad appears and waiting for long periods of time, there are no further calls to any of the ad delegate methods until the user interaction terminates. It looks like no new ads are fetched while in user interaction mode.
I want to simply pause the iAd banner in my app. When the user double clicks the home button to go to the multitasking screen, I made it so the app pauses itself which works perfectly fine. But the iAd banner keeps animating itself which looks kind of weird. A live iAd banner in a frozen app...
So how can I programmatically pause an iAd banner (ADBannerView)?
Or should I just remove it until the app is in the foreground again?
Since it's just a UIView, it's probably best to just set it's 'hidden' property to YES in viewWillDisappear (or viewDidDisappear) and then unhide it in viewWillAppear.
Another approach would be to grab a screencapture of the rectangle representing the banner, overlay an UIImageView on top of the banner and display the screen cap there. But I think that's a bit overkill.
I am working on a sprite kit game project and I got an issue on iAd, the Ad works fine, till I not click the ad. But when i click the ad it restart my whole game, and I am using only one iAd for my entire game.
The implementation of iAd is in my UIViewController class.
I know these two methods related to my issue but I don't know how to use them:
-(BOOL)bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
-(void)bannerViewActionDidFinish:(ADBannerView *)banner
I've tried every thing I know, but nothing comes out.
I have successfully implemented iAd into my App just this past week, but when my fill rate was very low I looked into it, and I realize I have a problem. My iAd banner is correclty displayed on the first screen the user sees, and that is the only screen on which the banner ad is displayed by my design. I setup a singleton class to manage the ads, and I'm expanding it to display on additional screens in an upcoming release. However, when I push another view controller to the front that doesn't display ads, my iAd delegate methods:
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
- (void) bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
are still being called every 3 minutes as though the view is active.
Is there a way to temporarily disable iAd from trying to refresh? thanks in advance.
Since I'm not showing ads on all of the pages, I create/release the ad object when my view controller that is showing ads is displayed/not-displayed (and set the delegate to nil), and this prevents any ads/delegate functions on view controllers that are not currently displayed from being displayed.
In my iPad app that supports all the device orientation, I add an adBannerView to the main view.
So far so good. It works and the ad rotates as expected.
If I click on a particular ad this is visualized full-screen, and when I close it I get back to my app.
The problem is that if you rotate the device while you are visualizing the full-screen ad, this rotates correctly, but when you close it and come back to the app the view is not rotated.
How to solve this? Please help or I will destroy my iPad! ;-)
Basically, you want the
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
method to be called again...
To do that, when the user closes the iAd, simply execute:
UIViewController *correctOrientation = [[UIViewController alloc]init];
[self presentModalViewController:correctOrientation animated:NO];
[self dismissModalViewControllerAnimated:NO];