@jandrad Thanks jandrad all fixed. I'm such an idiot!
[CODE] AdViewController (iAds + AdMob)
(59 posts) (18 voices)-
Posted 1 year ago #
-
Hello,
jandrad's code works well.
The only problem I am facing right now is that the particle system I use for special effect (like fire) is getting very blurry. All other images look fine though.
This issue starts happening when iAd starts showing up. No issue was found only when AdMob was shown.
Does anybody experience this interference issue with Particle System and iAd?Thanks in advance
Posted 1 year ago # -
I've tested @jandrad code (only with iAd), and it works OK.
But it is important to:
- enable the autorotation using the root view controller, otherwise the iAd won't be displayed correctly.I tried to workaround this issue by manually rotating the iAd view, but since iOS 4.1 (bug in 4.1) it stops receiving touches.
So if you want to use iAd + cocos2d + iOS 4.1 use @jandrad code and make sure that the autorotation is using the UIViewController.
#define GAME_AUTOROTATION kGameAutorotationUIViewControllerAlternative: If your game only uses the Portrait orientation, then you are free to use the "autorotation" (no autorotation) method that you want.
Posted 1 year ago # -
I also agree with Riq.
I had hard time trying to make autorotation work using 'non-root' view controller last week.
After I have converted it to use the ROOT view controller, it works like a charm in my landscape mode game.Posted 1 year ago # -
Another tip:
Don't try to place the iAd logic in another view controller. Just use the
RootViewControllerthat is created by default by the templates, and replace it with the one that @jandrad posted here.I tried for more than 4 hours to have 2 view controllers:
- The RootViewController
- and an extra "AdViewController as a "child" of the RootViewController but I couldn't see any ad.Posted 1 year ago # -
I ran into the multiple view controller nightmare a few weeks ago, the following from apple wasn't particularly enlightenting;
Note: If you want to divide a single screen into multiple areas and manage each one separately, use generic controller objects (custom objects descending from NSObject) instead of view controller objects to manage each subsection of the screen. Then use a single view controller object to manage the generic controller objects. The view controller coordinates the overall screen interactions but forwards messages as needed to the generic controller objects it manages.
I needed the cocos2d View to remain in portrait mode while a subview (the interface) rotated. I ended up having to remove the RootViewController to get it to work. Still no idea whether this is me being a muppet or just the way it is.
Posted 1 year ago # -
In iOS 4.0 only (not 4.1), the banner view is visible with the above mentioned code.
Simple hack that make it works OK both in iOS 4.0 and 4.1:
// somewhere at init time: [banner.view setHidden:YES]; // and before animation the view, just add this line [banner.view setHidden:NO];Posted 1 year ago # -
I am using the AdViewController in my game Immunogen. It works well but when I click on an AdMob ad the ad shows but when I click the done button it comes back to a blank screen with just the AdMob ad on it...is anyone else having this issue?
Posted 1 year ago # -
Where can I get the AdMobView class?
It fails to build because I don't have that class. Or could you update your code so it only works with iAd?Posted 1 year ago # -
Anyone???
Posted 1 year ago # -
Where can I get the AdMobView class?
I believe its in the admob developer sdk. http://www.admob.com
There is a sample app that includes it, if I remember correctly.Posted 1 year ago # -
Could someone please post a sample project with this code working? I can't display the ads...
Thanks in advance!Posted 1 year ago # -
I fixed some issues and changed the way the ads are displayed. I made a repository in github with a sample project.
https://github.com/jandrad/AdRootViewController
You need to replace the RootViewController, the autorotation now supports both CCDirector and UIViewController
Hope it helps!
Posted 1 year ago # -
It works fine for me, thank you very much. I'm sorry I haven't got much experience with Objective-C, but how can I change it to support landscape only?
Posted 1 year ago # -
Uncomment these lines on the orientationChanged: method of the AdRootViewController
//if ((orientation == UIDeviceOrientationLandscapeLeft) || (orientation == UIDeviceOrientationLandscapeRight)) //{ [[CCDirector sharedDirector] setDeviceOrientation:(ccDeviceOrientation)orientation]; [self updateBannerViewOrientation]; //}and these one in the shouldAutorotateToInterfaceOrientation:
return YES;//( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );Posted 1 year ago # -
Thank you so much! It works!
Posted 1 year ago # -
I added support for iPad, check it out!
Posted 1 year ago # -
Two questions left:
1. How can I remove the ad in certain scenes? [viewController removeBannerAd]; does not work...
2. What exactly do I have to write in GameConfig.h to define my Admob ID?Posted 1 year ago # -
In the .m file, I call [viewController removeBannerAd];
And in the .h file, I added "AdViewController* viewController;"Posted 1 year ago # -
By just declaring an AdViewController, you are not accessing the same instance initialized in you AppDelegate. You could access the one in your App Delegate declaring it as a property.
Example:
1.Declare your viewController as a property in you AppDelegate.h
@property (nonatomic, retain) AdRootViewController *viewController;2. Since the property was declared as a retain property, you need to initialize an AdRootViewController instance and release it as soon as you assign it to your viewController property. Replace your viewController Initialization with this:
// Init an AdRootViewController AdRootViewController* controller = [[AdRootViewController alloc] initWithNibName:nil bundle:nil]; controller.wantsFullScreenLayout = YES; //Assign the viewController self.viewController = controller; [controller release];3. Now you can access the viewController via the AppDelegate. On your scene you can import you AppDelegate.h and AdRootViewController.h and tell the controller to display the ad. Like this:
AdRootViewController* viewController = [(iAdsTestAppDelegate*)[[UIApplication sharedApplication] delegate] viewController]; [viewController addBannerAd]; [viewController setAdBannerPosition:kAdBannerPositionBottom];This is not the only way to access the viewController. Basically it depends on you. This is pure basic knowledge of how Objective -C works. You should read Apple's documentation on that matter, but I hope it was useful.
Posted 1 year ago # -
Thank you! I don't have a lot of knowledge in objective-c, I guess I'll have to read Apple' documentation…
Posted 1 year ago # -
Thanks jandrad for the AdRootViewController, it took me only one hour to set up iAds & admob in my application.
But I have a little question.
Could I detect when a "addInterstitialAd" is launched? I need to stop music when is launched and start when user close the ad.
Posted 1 year ago # -
hi guys , thanks jandrad for some great code but im having problems, on my device running 4.1 firmware i cant get iad to load.now it loads fine on simulator, this is not same problem as other people becuase on the log screen its telling me iad loaded but does not appear on the iphone screen totally stumped spent hours on it.if you can help would apretiate it, using ccdirector as trying to make game compatable for the iphone 3g and older devices. colyn
Posted 1 year ago # -
Hi,
I'm still struggling with this. I've got about 3 different methods for combining Admob with iAd and none of them are quite right. I've got myself all confused.
Has anyone got this working for the new Google Admob that uses GADBannerView.h?
Thanks,
TravisPosted 3 months ago # -
The size of the adMob (libGoogleAdMobAds.a) is 8.1Mb.
Does the full file goes to archive? My app size has increased too much after integrating it. Any suggestions on that?
Posted 3 months ago # -
Hi there group! I was wondering if anyone could provide me some insight on how they developed their app from a monetization standpoint. Meaning was the app specifically built around monetization, or was the app born from a cool idea and you simply decided to place ads in-app for monetization. I am curious to see how other devs can learn from each other to create a better monetization strategy from other group users experiences.
Posted 2 months ago #
Reply
You must log in to post.