iAds not showing - ios

I have implemented the following code:
-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:0];
[UIView commitAnimations];
}
And published the app to the app store. Ads are not showing up in the app store app nor am I getting any information in iTunes Connect when I go to view iAd information. Is this code right and the only code I have to put? In the storyboard, I have the iAd at the bottom of the screen connected to the delegate and I also have this in ViewController.h
#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
#import <AudioToolbox/AudioToolbox.h>
#interface ViewController : UIViewController <ADBannerViewDelegate,UIPickerViewDelegate,UIPickerViewDataSource> {
(Showing that I have imported the iAd Framework and have the ADBannerViewDelegate)

Related

iAds not showing the banner

My app has been accepted for iAds advertising network, but after I download the app, I do not see the banner ad appears and I have to wait one week but still not see. I don't know if the app itself is faulty or not, here's the code I've used.
ViewController.h
#import <iAd/iAd.h>
#interface ViewController : UIViewController <ADBannerViewDelegate>
ViewController.m
#pragma mark iAd Delegate Methods
-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:0];
[UIView commitAnimations];
}

integrate iAds with adMob on iOS together

I've used the following code for iAd integration...
-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:0];
[UIView commitAnimations];
}
I know the code for integrating Google's AdMob, but do I just add the code inside these iAd methods i used?
Go to Google's AdMob iOS guide site. That site gives you a tutorial of how to implement AdMob banners. Then you post that code in didFailToReceiveAdWithError and that'll mediate your iAd, AdMob banners. However, you should place the BELOW code in viewDidLoad instead.
UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
Also, it'll only mediate if you create an account with Google's AdMob and implemented the mediation settings. For example if you chose higher CPM for iAd then iAd will show first. If you put lower CPM for AdMob, AdMob will show when iAd fails to show.

iAds on 3.5 Iphone not appearing

I have set up iAds for my app, but for whatever reason, they only appear on the iphone 4 inch and not the 3.5 inch. First, I thought it had something to do with the Auto Layout, so I made sure the BannerView appeared in both screen sizes. After doing so, I ran and still would not work.
Here is the code I used to tell the bannerView what to do. This is in the ViewController.m file.
#pragma mark iAd Delegate Methods
-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:0];
[UIView commitAnimations];
}
Also, this is being done in Spritekit if that matters.
Thanks for helping, and I'm pretty new to coding so something that may seem obvious, I might have easily not noticed.
You cannot animate the alpha of an object. Alternatively, you should be modifying it's transparency via it's opacity:
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
[UIView animateWithDuration:1.0 animations:^{
banner.layer.opacity = 1.0f;
}];
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
[UIView animateWithDuration:1.0 animations:^{
banner.layer.opacity = 0.0f;
}];
}

iAd how to hide and show ads at a specifc point in my app

my goal is to have my iAd show at the main menu screen(which I already accomplished) but when the user push a button to start the game I want the ad to go away and when the game ends the ad to reappear...I saw a lot of other similar questions but none had answers(searched for hours :/ ). also checked the documentation and couldn't find a logical solution, I'm also a newbie,thanks!
*update the code im working with .h file
-(void) bannerViewDidLoadAd:(ADBannerView *)banner
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
}
-(void) bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:0];
[UIView commitAnimations];
}

iAd Banner is not working

I'm trying to get a banner in my app, but since I added the banner, the app won't start.
I get an error saying:
Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named ADBannerView'
Code in .h file:
#import <iAd/iAd.h>
#interface FirstViewController : UIViewController <ADBannerViewDelegate>
{
ADBannerView *banner;
}
#property (nonatomic,assign) BOOL bannerIsVisible;
#property (nonatomic,retain) IBOutlet ADBannerView *banner;
Code in .m file:
#synthesize banner, bannerIsVisible;
-(void)bannerViewDidLoad: (ADBannerView *)abanner
{
if(!self.bannerIsVisible)
{
[UIView beginAnimations:#"animatedAdBannerOn" context:NULL];
banner.frame=CGRectOffset(banner.frame, 0.0, 50.0);
[UIView commitAnimations];
self.bannerIsVisible=YES;
}
}
-(void)bannerView:(ADBannerView *)aBanner
{
if(!self.bannerIsVisible)
{
[UIView beginAnimations:#"animatedAdBannerOff" context:NULL];
banner.frame=CGRectOffset(banner.frame, 0.0, -320.0);
[UIView commitAnimations];
self.bannerIsVisible=NO;
}
}
What do you think is wrong?
You must add iAd.framework into your project.
Take this code:
#import <iAd/iAd.h>
#interface ViewController : UIViewController <ADBannerViewDelegate> {
}
#end
.m file:
#implementation ViewController
-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[banner setAlpha:0];
[UIView commitAnimations];
}
#end

Resources