Reputation: 4980
I have implemented iAds into my app, but I'm getting very odd errors when I run the app on the simulator. They tend to vary, but the most common error is Error in Loading Banner! Error Domain=ADErrorDomain Code=4 "The operation couldn’t be completed. Application has iAd Network configuration error" UserInfo=0xa368250 {ADInternalErrorCode=4, ADInternalErrorDomain=ADErrorDomain, NSLocalizedFailureReason=Application has iAd Network configuration error}
And lately:
Error Domain=ADErrorDomain Code=5 "The operation couldn’t be completed. Banner view is visible but does not have content" UserInfo=0xa3a0c40 {ADInternalErrorCode=5, ADInternalErrorDomain=ADErrorDomain, NSLocalizedFailureReason=Banner view is visible but does not have content}
I can't figure out why this is happening. I double checked to make sure that the simulator is connected to wifi, and the clock is correctly set as well. This is how I implemented iAds:
Relevant code in the .h:
#import "iAd/ADBannerView.h"
@interface myViewController : UIViewController <ADBannerViewDelegate> {
ADBannerView *adView;
}
@property (nonatomic, retain) IBOutlet ADBannerView *adView;
And all the relevant code in my .m:
@synthesize adView;
...
- (void)viewDidLoad {
adView.delegate = self;
adView.hidden = YES;
[super viewDidLoad];
}
...
-(void)bannerView:(ADBannerView *)banner
didFailToReceiveAdWithError:(NSError *)error{
NSLog(@"Error in Loading Banner! %@", error);
}
-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
NSLog(@"iAd banner Loaded Successfully!");
}
-(void)bannerViewWillLoadAd:(ADBannerView *)banner{
NSLog(@"iAd Banner will load!");
}
-(void)bannerViewActionDidFinish:(ADBannerView *)banner{
NSLog(@"iAd Banner did finish");
}
Then I dragged an AdBannerView onto the view and connected the outlets in the view controllers. Is this the correct way to do this? If so, what could be causing this error? The app doesn't crash... the ads simply don't appear. Supposedly this is a common issue but I could never track down a fix.
I have enabled push notifications for my provisioning profile, and tried to find a section for iAds but could not. Could this be the issue?
I've also ensured that the AdBannerView that I'm using is exactly 320x50. I tried again this morning with the same code and it's the same issue. Should I just go ahead and assume it's an Apple / iAd issue and submit my app assuming the above is implemented correctly?
Upvotes: 0
Views: 1867
Reputation: 4980
There must have been an issue with the iAd network. Tested exact same code a day later and it magically work now on the device.
Upvotes: 1
Reputation: 627
.h file
#import <iAd/iAd.h>
@interface MainViewController : CDVViewController <ADBannerViewDelegate>
@end
.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];
}
make sure that is before your @end in your mainviewcontroller
last just drag and drop the adbanner on your storyboard and ctrl+click and drag from the banner up to file's owner under placeholders, it's the gold box icon and then hit delegate.
Upvotes: 2