Anyone implement iAds in their T2D iPhone game
by Michael Cozzolino · in iTorque 2D · 07/09/2010 (1:38 pm) · 19 replies
Just wondering if it is difficult. Still waffling back and forth on my game being for pay or ad supported.
About the author
Indie Developer in the Albany NY area. iOS, PC, Mac OSX development. http://itunes.apple.com/us/artist/michael-cozzolino/id367780489
#2
though if you have admob yo want to switch anyway cause you are open to be rejected just due to 3.3.9 from toS
I would recommend giving mobclick a go. it will soon support iAd when available and fills with "regular ad" otherwise. also it combines many ad networks leading to adequate fillrates
07/09/2010 (4:17 pm)
just keep in mind that iAds are available on os4 devices only ...though if you have admob yo want to switch anyway cause you are open to be rejected just due to 3.3.9 from toS
I would recommend giving mobclick a go. it will soon support iAd when available and fills with "regular ad" otherwise. also it combines many ad networks leading to adequate fillrates
#3
- add iAd framework to project;
- in iPhoneOGLVideo.mm:
find "- (void)layoutSubviews {"
and add there:
UIWindow* window = [UIApplication sharedApplication].keyWindow;
UIViewController *glView = [[UIViewController alloc] init];
[window addSubview: glView.view];
ADBannerView *adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
[glView.view addSubview:adView];
for sure it works on iOS 4.1 on ipod (on device),
issues: you need to fit sizes for view and handle events: an iAd received, an error, release the stuff etc.
10/30/2010 (10:52 am)
- check itunes-connect contracts - iAd contract should be green-label marked;- add iAd framework to project;
- in iPhoneOGLVideo.mm:
find "- (void)layoutSubviews {"
and add there:
UIWindow* window = [UIApplication sharedApplication].keyWindow;
UIViewController *glView = [[UIViewController alloc] init];
[window addSubview: glView.view];
ADBannerView *adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
[glView.view addSubview:adView];
for sure it works on iOS 4.1 on ipod (on device),
issues: you need to fit sizes for view and handle events: an iAd received, an error, release the stuff etc.
#4
11/25/2010 (9:33 pm)
Vyacheslav, That works to get them in, but the UIView is capturing all the Touch events.
#5
You may add this code to TGBAppDelegate.mm
and from scripts you can just do:
and it will create iAd at bottom side in portrait orientation.
11/26/2010 (8:27 am)
This is better implementation:You may add this code to TGBAppDelegate.mm
ConsoleFunction(openAd, void, 2, 2, "openAd(1) "
"launches iAds")
{
argc;
UIWindow* window = [UIApplication sharedApplication].keyWindow;
UIViewController *glView = [[UIViewController alloc] init];
glView.view.frame = CGRectMake(0.0f, 430.0f, 320.0, 50.0);
[window addSubview: glView.view];
ADBannerView *adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
[glView.view addSubview:adView];
}and from scripts you can just do:
openAd(1);
and it will create iAd at bottom side in portrait orientation.
#6
11/26/2010 (5:25 pm)
Out of curiosity, what sort of revenue have any of you guys received from using iAds? Is it worth putting the ads in your games?
#7
http://www.silhouette-studios.com.au/index.php?option=com_content&view=article&id=83:derailed&catid=39:captify-content&Itemid=105
So ill let you know how it affects sales in the coming weeks through my blog www.ashleyleach.com.au
11/29/2010 (2:40 am)
I'm adding them into DerailedHDhttp://www.silhouette-studios.com.au/index.php?option=com_content&view=article&id=83:derailed&catid=39:captify-content&Itemid=105
So ill let you know how it affects sales in the coming weeks through my blog www.ashleyleach.com.au
#8
have you gotten the callbacks to work? I tried but the iads callbacks are not being called.
02/02/2011 (11:28 am)
@yacheslav, ashley,have you gotten the callbacks to work? I tried but the iads callbacks are not being called.
#9
The ad appears, it seems to work ok, it appears at the bottom of the screen in portrait. Click the ad and everything is cool. return to the app and the ad is now at the top of the screen.
@Jonny did you ever get the callbacks to work? I bet we have to write wrappers or whatever in TGBAppDelegate.mm for each callback we would want to implement.
I would also think that GG would ad this to the project along with GameCenter. I am building a game that is perfect for iTGB, I already know how to use iTGB but if I cannot get these things to work then I will have to use a different game engine where these things are ready and available.
04/15/2011 (11:15 am)
I have also tried this and while it works, sort of, there are issues. The ad appears, it seems to work ok, it appears at the bottom of the screen in portrait. Click the ad and everything is cool. return to the app and the ad is now at the top of the screen.
@Jonny did you ever get the callbacks to work? I bet we have to write wrappers or whatever in TGBAppDelegate.mm for each callback we would want to implement.
I would also think that GG would ad this to the project along with GameCenter. I am building a game that is perfect for iTGB, I already know how to use iTGB but if I cannot get these things to work then I will have to use a different game engine where these things are ready and available.
#10
04/18/2011 (5:24 pm)
Not yet, Henry. I was trying to get it to work with landscape mode but ran into problems.
#11
07/11/2011 (7:34 am)
Has anyone got iAds working. I have added the code provided by Vyacheslav Klymenko in #5 but once I touch the iAd banner the test ad pops up ok and then after I close the ad touch doesnt work in the game. Any ideas why this is happening?
#12
The problem with #5 is that the UIViewController instance is not integrated with the other app windows (a solution might be to integrate it with the main window)
I have a thread on this, but it is still a work in progress
www.garagegames.com/community/forums/viewthread/126472
07/12/2011 (9:30 am)
@HiteshThe problem with #5 is that the UIViewController instance is not integrated with the other app windows (a solution might be to integrate it with the main window)
I have a thread on this, but it is still a work in progress
www.garagegames.com/community/forums/viewthread/126472
#13
@Pedro: I just got mobclix working on one of my apps. Mobclix supports iads and admob so it's pretty neat. If you are interested I'll try to get a resource up this weekend for everyone.
07/12/2011 (12:37 pm)
@Richard: I have iAds in a native cocoa flashlight app and the revenue is really good. I only get about 8 - 10 downloads a day but that gives me 1-2 dollars each day! Imagine if you had alot of downloads. I definately recommend iAds especially if your app is targeted for the u.s market (iads is not available worldwide). @Pedro: I just got mobclix working on one of my apps. Mobclix supports iads and admob so it's pretty neat. If you are interested I'll try to get a resource up this weekend for everyone.
#15
Step 1
Add iAd fraemwork
Step 2
Add UIViewController subclass with header file and call it ViewController
Step 3
Update ViewController.m file to this
Step 4
Update ViewController.h file to this
Step 5
Add the following at the top in TGBAppDelegate.mm file
Step 6
Add the following to the -(void)applicationDidFinishLaunching:(UIApplication *)application function in the TGBAppDelegate.mm file
07/29/2011 (7:56 am)
Finally, with the help of Pedro's thread www.garagegames.com/community/forums/viewthread/126472 and some searches on the web I have finally managed to get iAds working. This is what I did:Step 1
Add iAd fraemwork
Step 2
Add UIViewController subclass with header file and call it ViewController
Step 3
Update ViewController.m file to this
#import "ViewController.h"
@implementation ViewController
- (void)viewDidLoad
{
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.hidden = YES;
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
adView.delegate = self;
[self.view addSubview:adView];
[super viewDidLoad];
}
-(void)viewDidUnload
{
adView.delegate = nil;
adView = nil;
}
-(void)dealloc
{
adView.delegate = nil;
[adView release];
adView = nil;
[super dealloc];
}
#pragma mark ADBannerViewDelegate methods
-(void)bannerViewDidLoadAd:(ADBannerView *)banner
{
adView.hidden = NO;
}
-(void)bannerViewActionDidFinish:(ADBannerView *)banner
{
self.view.frame = CGRectMake(0.0f, 0.0f, 320.0, 50.0);
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
adView.hidden = YES;
}
@endStep 4
Update ViewController.h file to this
#import <UIKit/UIKit.h>
#import <iAd/iAd.h>
@interface ViewController : UIViewController <ADBannerViewDelegate> {
ADBannerView *adView;
}
@endStep 5
Add the following at the top in TGBAppDelegate.mm file
#import "ViewController.h"
Step 6
Add the following to the -(void)applicationDidFinishLaunching:(UIApplication *)application function in the TGBAppDelegate.mm file
ViewController *View = [[ViewController alloc] init]; View.view.frame = CGRectMake(0.0f, 0.0f, 320.0, 50.0); [window addSubview:View.view];
#16
Thanks everyone for the contributions!
07/29/2011 (12:47 pm)
I'm gonna have to take this for a spin and see how well it works. If I feel it is low risk, I will see about getting it into 1.5 If I find some problems, I'll try to make it an official tutorial for the documentation post 1.5 launch.Thanks everyone for the contributions!
#17
I did add one more method for when a full screen ad appears. (see below)
My implementation used the same settings as the example (phone + portrait)
Huge thanks for all who figured this out.
08/22/2011 (10:47 am)
For what it is worth, this worked for me as described. I did add one more method for when a full screen ad appears. (see below)
My implementation used the same settings as the example (phone + portrait)
- (BOOL) bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave
{
// add your application specific action here
return YES;
}Huge thanks for all who figured this out.
#18
I will post a new resource about iAD in a couple days.
08/22/2011 (11:24 am)
Does this work in landscape? I managed to get my version working but in portrait *only*.I will post a new resource about iAD in a couple days.
Torque Owner Johnny Vo