iAd Banner - Technical only

Previous topic - Next topic

ampos

In the spanish forums, we have the files modified to get iADs working for any iOS 4.x

Code (glbasic) Select
http://www.glbasic.com/forum/index.php?topic=5932.new;topicseen#new

Thanks to msx2 for the modifications.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

kaotiklabs

Any help about landscape mode?

I have tried several solutions without luck.
Vote Cthulhu! Because the stars are right!!!!
Ia Ia Cthulhu F' tang!

msx

Quote from: Crivens on 2011-Mar-25
Strange. Maybe it's because you are now compiling with XCode 4? I am using XCode 3 to compile my new free version (not upgrading until this is done) and the problem happens. Although I'm sure it didn't happen before (when Matchy first posted). Maybe the one on the store and Matchy's one were compiled on an older version and now don't work on 4.3? Out of interest can you purchase your own app? Do they charge you for it? Infact yours is free. Why not purchase it and see what happens?

I've attached some screenshots of your app from a 3GS. It shows before clicking on the ad, then the ad, then after the ad. At which point nothing works but clicking on the ad again. The same thing happens on my 4G iPod Touch (should be almost identical to iPhone 4).

Cheers

Tested with SDK 4.2 and SDK 4.3 and shows the same bug, but only in IOS 4.3. It works without problems in iOS 4.1.

Kitty Hello


Crivens

I posted code earlier in this thread to allow it to work with adverts if at the top of the screen. I only hacked it together but it seems to work. Try the Rotaslider free version to see it working.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Crivens

Ok, so my modified version I posted earlier in this thread allows iAds to work properly after being selected (ie. rest of screen doesn't freeze up), or at least if you only use an iAd at the top of the screen it works (anyone fixed that?), but has anyone implemented ads in WebOS or Android?

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

ampos

Quote from: Crivens on 2011-Aug-03
Ok, so my modified version I posted earlier in this thread allows iAds to work properly after being selected (ie. rest of screen doesn't freeze up), or at least if you only use an iAd at the top of the screen it works (anyone fixed that?), but has anyone implemented ads in WebOS or Android?

Cheers

I am really lost here... which one is the good version?

I mean, Crivens seems to have fix some kind of error on wrapper after pressing the iAD and I can not find in this thread his modification, and we have in the spanish forum http://www.glbasic.com/forum/index.php?topic=5932.0 a version that works on any 4.x (Matchy's original code just worked only in 4.2+).

It could be great if a new post about iADs is created with the source code in the very first post with both fixes implemented.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Crivens

 It's in here somewhere. Is very slightly changed. While it fixes ads at the top of the screen so it doesn't all freeze after selection, it doesn't quite work for if the ad is at the bottom of the screen

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

ampos

Seriously, I dont see anything modified by you in this thread...
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Crivens

Hmm, I will have a look tomorrow. Definitely posted it plus it's being used in the free Rotaslider app.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Crivens

Strange I could swear I posted the full code but can't find it now. Perhaps in a different thread. I do describe the fix though:-
QuoteHmm, haven't had much chance to look into this (not that I really know what I'm doing in XCode) but I found chucking in the self.view.frame=CGRectMake..etc. and bannerview.frame=CGRectMake..etc commands into the viewDidAppear section seemed to free it up from freezing after looking at an ad. Seems to work well if I change the Y coords to 0 if using a portrait ad that appears at the top of the screen, but can't seem to get it to work properly for the bottom of the screen. Repeating the exact same commands from the init routine works for showing it on the screen again, and control returns to the rest of the screen, but the ad itself seems to have moved it's "zone" if you see what I mean and touching it touches whats underneath). Strange...
I'll dig out the code tomorrow and post it here.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

Crivens

Ok, think I've found the right version of AppViewController.mm. As I said before I only fiddled with it a bit and got it to work (ie. unfreeze after selection) for an ad at the top of the screen. One at the bottom doesn't quite work after selection (it unfreezes but the iAd itself isn't selectable anymore and any "clicks" will select underneath the iAd.
Code (glbasic) Select
// This filename is "AppViewController.mm"
#import "AppViewController.h"
@implementation AppViewController
@synthesize appView = _appView;
@synthesize bannerView; // = _bannerView;
@synthesize appWindow = _appWindow;
# pragma mark -
# pragma mark View
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"viewDidLoad");
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.view.frame = CGRectMake(0,0, 768, 50);
bannerView.frame=CGRectMake(0,0, 768, 50);

//self.view.frame = CGRectMake(0,480-50, 768, 50);
//bannerView.frame=CGRectMake(0,480+50, 768, 50);
NSLog(@"viewDidAppear");
}
//- (void)viewWillAppear:(BOOL)animated {
// NSLog(@"viewWillAppear");
// if (bannerView) {
// UIInterfaceOrientation orientation=self.interfaceOrientation;
// [self changeBannerOrientation:orientation];
// }
//}
- (void)dealloc {
[super dealloc];
}
//- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
//
// return (interfaceOrientation == UIInterfaceOrientationPortrait) | (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) | (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
//}
#pragma mark -
#pragma mark ADBanner
//- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
//if (bannerView) {
// [self changeBannerOrientation:toInterfaceOrientation];
//}
// NSLog(@"shouldAutorotate");
//}
- (void)changeBannerOrientation:(UIInterfaceOrientation)toOrientation {
NSLog(@"changeBannerOrientation");
if (UIInterfaceOrientationIsLandscape(toOrientation)) {
bannerView.currentContentSizeIdentifier=ADBannerContentSizeIdentifierLandscape;
self.view.frame=CGRectMake(0,0, 320, 120);
} else {
bannerView.currentContentSizeIdentifier=ADBannerContentSizeIdentifierPortrait;
self.view.frame=CGRectMake(0,0, 480, 100);
}
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
NSLog(@"bannerViewDidLoad");
// self.bannerView.hidden=NO;
[self showBanner];
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
// self.bannerView.hidden=YES;
// NSLog(@"bannerView");
NSLog(@"E R R O R: '%@'",error);
// [self hideBanner];
}
- (void)createBannerView {
NSLog(@"Banner creating...");
_appWindow = [[UIApplication sharedApplication] keyWindow];

bannerView=[[[ADBannerView alloc] init] autorelease];
bannerView.delegate=self;

//self.view.frame = CGRectMake(0,480-50, 768, 50);
//bannerView.frame=CGRectMake(0,480+50, 768, 50);

self.view.frame = CGRectMake(0,0, 768, 50);
bannerView.frame=CGRectMake(0,0, 768, 50);
bannerView.currentContentSizeIdentifier=ADBannerContentSizeIdentifierPortrait;

[self.view addSubview:self.bannerView];

[_appWindow addSubview:self.view];
[_appWindow makeKeyWindow];
// [_appWindow makeKeyAndVisible];
}
- (void)showBanner {
NSLog(@"Show banner");
CGRect bannerFrame=bannerView.frame;
bannerFrame.origin.y=0;
[UIView beginAnimations:@"showBanner" context:NULL];
bannerView.frame=bannerFrame;
[UIView commitAnimations];
}
- (void)hideBanner {
NSLog(@"Hide banner");
CGRect bannerFrame=bannerView.frame;
bannerFrame.origin.y=-bannerFrame.size.height;
bannerView.frame=bannerFrame;
}
#pragma mark -
#pragma mark GLB
- (void)initBanner {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
[self performSelectorOnMainThread:@selector(createBannerView) withObject:nil waitUntilDone:YES];
[pool release];
}
@end
extern "C" void glb_BannerInit() {
AppViewController * UIGlbasic;
UIGlbasic = [[AppViewController alloc] init];
[UIGlbasic createBannerView];
// [UIGlbasic release];
[UIGlbasic retain];
}
extern "C" void glb_ShowBanner() {
AppViewController * UIGlbasic;
UIGlbasic = [[AppViewController alloc] init];
[UIGlbasic showBanner];
// [UIGlbasic release];
[UIGlbasic retain];
}
extern "C" void glb_HideBanner() {
AppViewController * UIGlbasic;
UIGlbasic = [[AppViewController alloc] init];
[UIGlbasic hideBanner];
// [UIGlbasic release];
[UIGlbasic retain];
}


Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

ampos

Since iOS 5.x I have found that my app display a white box when the iAD were not loaded.

Last week I updated the app and sent it to Apple. They have rejected it because this white box.

Perhaps someone could update our parser to avoid this problem.

Quote from Apple:

Quote7.2

We found that your app displays an empty iAd banner when ad content is not available, which is not in compliance with the App Store Review Guidelines.

Please see the attached screenshot/s for more information.

The banner within the app should be hidden whenever ad content is not being served by iAd. To handle the case where ad content is not available, you need to implement a banner view delegate. An example code snippet is included here for your convenience. Additionally, you may wish to review the section "Working with Banner Views" of the iAd Programming Guide.

Banner View Delegate to Remove a Banner View When Advertisements are Not Available:

- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible)
{
[UIView beginAnimations:@"animateAdBannerOff" context:NULL];
// assumes the banner view is at the top of the screen.
banner.frame = CGRectOffset(banner.frame, 0, -50);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Crivens

Yeah I can see that with mine. Plus the iAds don't show until you exit the app and then restart it. It's still there and you can click it but can't see it until restart.

Unfortuantly I'm moving to paid only apps for a bit to see how that pans out with sales, so I'm not bothered with iAds for the moment. Hopefully someone else can make a 100% ios5 compatible iad wrapper.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

msx

Has anyone managed to solve this problem?. Does it show banners with this code on IOS 5 or else only a white box?.

Thank you  :good: