BASIC

Author Topic: iAd Banner - Technical only  (Read 41351 times)

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1594
    • View Profile
    • AMpostata Website
Re: iAd Banner - Technical only
« Reply #135 on: 2011-Apr-25 »
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

Offline kaotiklabs

  • Dr. Type
  • ****
  • Posts: 313
  • Spain is diferent
    • View Profile
Re: iAd Banner - Technical only
« Reply #136 on: 2011-May-03 »
Any help about landscape mode?

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

Offline msx

  • Prof. Inline
  • *****
  • Posts: 773
    • View Profile
Re: iAd Banner - Technical only
« Reply #137 on: 2011-May-05 »
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.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10714
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: iAd Banner - Technical only
« Reply #138 on: 2011-May-05 »
Oh my.
Trucidare!?

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: iAd Banner - Technical only
« Reply #139 on: 2011-May-05 »
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.

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: iAd Banner - Technical only
« Reply #140 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
Current fave quote: Cause you like musicians and I like people with boobs.

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1594
    • View Profile
    • AMpostata Website
Re: iAd Banner - Technical only
« Reply #141 on: 2011-Aug-11 »
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

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: iAd Banner - Technical only
« Reply #142 on: 2011-Aug-11 »
 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.

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1594
    • View Profile
    • AMpostata Website
Re: iAd Banner - Technical only
« Reply #143 on: 2011-Aug-11 »
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

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: iAd Banner - Technical only
« Reply #144 on: 2011-Aug-11 »
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.

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: iAd Banner - Technical only
« Reply #145 on: 2011-Aug-11 »
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:-
Quote
Hmm, 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.

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: iAd Banner - Technical only
« Reply #146 on: 2011-Aug-11 »
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.

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1594
    • View Profile
    • AMpostata Website
Re: iAd Banner - Technical only
« Reply #147 on: 2011-Dec-15 »
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:

Quote
7.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

Offline Crivens

  • Prof. Inline
  • *****
  • Posts: 913
    • View Profile
Re: iAd Banner - Technical only
« Reply #148 on: 2011-Dec-16 »
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.

Offline msx

  • Prof. Inline
  • *****
  • Posts: 773
    • View Profile
Re: iAd Banner - Technical only
« Reply #149 on: 2012-Feb-05 »
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: