The recently released Version 2.0 of cocos2d for iPhone deprecated the use of RootViewController in cocos2d projects. Previously, we showed you how to integrate AdMob ads by leveraging the RootViewController. Here, we show you the updated way of integrating AdMob ads into cocos2d v2.0 projects.
All of your initialization can now be done in the layer where you’d like the ad to show. In your layer’s init function, you can set up your ad banner as you would normally.
init
-(id) init { // Do other layer initialization here. adBanner_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner]; adBanner_.adUnitID = @"YOUR_ADMOB_PUBLISHER_ID"; adBanner_.delegate = self; …. }
The tricky part here is setting the rootViewController property for your GADBannerView and putting it into your view hierarchy. Version 2.0 of cocos2d uses a UINavigationController as its top-level view controller. The main OpenGL view is placed inside this controller. You want to set your rootViewController to be the main navigation controller.
AppController *app = (AppController*) [[UIApplication sharedApplication] delegate]; [adBanner_ setRootViewController:[app navController]];
There are performance considerations to think about when adding a GADBannerView into your hierarchy. Overlaying UIKit layers on top of OpenGL layers can lead to lower frame rates for apps that draw often. However, with newer hardware, this performance decrease is less of a concern. As always, we recommend that you profile your application’s performance to determine what works in your situation.
For our example, we will add the GADBannerView on top of the OpenGL view. This involves accessing the view being shown from the sharedDirector object.
[[CCDirector sharedDirector].view addSubview:adBanner_];
Remember that since you are creating GADBannerView objects, you will have to clean them up with dealloc as well.
- (void) dealloc { adBanner_.delegate = nil; [adBanner_ release]; [super dealloc]; }
You should now see AdMob ads show up in your cocos2d application. If there are any other integration topics you would like to see, or any technical questions you have, please let us know about them on the forum or check out our G+ page.
A new release of the DFA Reporting API, version 1.1, extends the ability of your applications to tap into the power and flexibility offered by our new reporting platform.
Using the DFA Reporting API, you can now take advantage of all of the report types in ReportBuilder:
The API contains support for CROSS_DIMENSION_REACH reports, but the backend currently does not. Support for these reports will be turned on at a later date and will be accessible through version 1.1.
CROSS_DIMENSION_REACH
Additionally, you may now set a list of recipients to be emailed when a scheduled report runs. We have paved the way for downloading reports in different formats, though currently CSV is the only available option.
CSV
We have taken the opportunity to make a few backwards incompatible changes to the API. It will not be standard procedure to make changes like this in minor version releases, but since the API is still relatively new, locking down the final structure of our API now will reduce changes later and ease development. These changes include:
dateRange
urls
customRichMediaEvents
activities
Our updated release notes page has a full list of changes for your reference. As always, we highly value your feedback and questions. Please join us on our forum whenever you’d like to reach us. - Joseph DiLallo, the DFA API Team
Today, we released v6.2 of the AdMob SDK for iOS developers. This release includes a number of bug fixes as well as some important changes for iOS 6 and the iPhone 5. This post will go through some important differences developers should keep in mind when working with AdMob v6.2. All of our developer docs have already been updated to reflect these change.
We’ve made a number of changes to add support for both iOS 6 and the iPhone 5. This means that you will need to use XCode 4.5 and build against iOS 6 when using our SDK. You can still support down to iOS 4.3 by setting your “Deployment Target” to iOS 4.3 in your project’s Application Target.
The iPhone 5 is powered by the A6 processor which uses the armv7s architecture, so targeting armv7s will optimize your app to run on iPhone 5. We’ve dropped support for the armv6 architecture and added support for the armv7s architecture in this release (we also still support armv7). New projects created via XCode 4.5 default to supporting armv7 and armv7s, meaning that this shouldn’t be an issue as long as you’re using the correct version of XCode.
If you’re targeting the armv7s architecture, you will not need to add the -all_load linker flag to your projects anymore. If you were using this specifically for AdMob, you can now safely remove the flag from the “Other Linker Flags” section of your project’s “Build Settings”. You will still need to have the -ObjC linker flag in this section.
We are now also using Apple’s Identifier for Advertising for personalization and reporting. You will have to link against the AdSupport framework in your applications when using the AdMob SDK in order to support this feature. You can do this by adding the AdSupport.framework to the “Linked Framework and Libraries” section of your application’s Target settings. Make sure that you link the framework using the “Optional” setting if your application can run on an iOS version below iOS 6.
Apple introduced Auto Layout for iOS 6 to help support multiple screen sizes. All of our AdMob banners have been updated to work with Auto Layout. When using Auto Layout (in code) with a GADBannerView, you must:
translatesAutoresizingMaskIntoConstraints
NO
You can download the latest SDKs from our downloads page. If you’ve got any other questions or concerns about using the new AdMob SDK, please ask us in the forum or check out our G+ page.
Last week, we caught up with Vishay Nihalani from the AdMob team in Mountain View, CA. Vishay is the Product Manager for the AdMob Mediation effort here at Google. Mediation helps developers easily integrate and manage multiple ad networks into their Android and iOS applications. Vishay was able to provide some useful insight on why AdMob built mediation, what the benefits are, and what to expect in the future. Let’s find out what he had to say.
Hello, Vishay. Thanks for taking the time to talk to us about AdMob Mediation! Can you tell us what prompted AdMob to develop a mediation framework?
That’s a great question. When Google acquired AdMob, we also acquired AdWhirl, an open source ad mediation solution that helped developers fill every ad request instead of only a few requests. The popularity of AdWhirl made it clear that mediation was something that developers wanted.
At Google, we decided to take the concept of AdWhirl a step further by integrating mediation directly within AdMob, allowing us to scale the product and add new features that developers need.
What is the benefit of switching to AdMob Mediation?
Developers should use mediation to make sure that no ad request goes unfilled. AdMob mediation in particular has some cool features that help you to maximize your revenue by using the highest paying networks first. Since many networks tend to focus on specific regions, AdMob allows you to set eCPM values at the country level as well.
Like AdWhirl, AdMob Mediation is free no matter how many impressions you serve, allowing you to scale your app and take full advantage of this feature.
Should I still use mediation if I’m only using AdMob?
Mediation is largely geared for multiple networks, but there are advantages to using mediation even if you’re only using AdMob. Using mediation, you can quickly serve house ads to all your users. You can use mediation to add a promotion advertising campaign for a new app you’ve just launched before showing a network ad, or to promote your other apps if the AdMob network has no ad to fill your request.
Why did AdMob decide to do client-side mediation as opposed to server-side integration?
One of our main goals with AdMob Mediation is to scale to as many ad networks as possible. Not all ad networks have server side APIs, and we didn’t want to have this barrier to joining our mediation offering.
Another huge benefit to client-side mediation is that it is transparent and neutral. Any third party network can easily plug into AdMob Mediation, and all interactions between the third-party SDK and the third-party ad server is completely independent of AdMob. A good example of this is the skyscraper format - even though the AdMob network doesn’t offer skyscraper ads, AdMob Mediation still supports third-party ad networks who want to serve skyscraper ads through mediation.
Finally, doing client-side mediation allows us to easily add new partners. We don’t have to wait for the next AdMob SDK release cycle to launch them.
Can you tell us about any new features coming to AdMob Mediation, or where the product is headed?
We’re planning to make it even easier to integrate mediation into your application by making all ad network placements mediated by default. This means you won’t need to swap out IDs when you switch to mediation. We want to make it easier to help maximize your revenue, and we have some features in the works that we think developers will be excited about!
Enough about mediation...Tell us about some of your hobbies/interests outside of work.
I play a ton of soccer and I love to travel. Sometimes I even travel to watch soccer. I attended the World Cup in 2010, and I’ve already blocked off my calendar for Brazil 2014!
Wow, that’s exciting! Other than the World Cup, what was the most exciting part about visiting South Africa?
I went shark cage diving with great white sharks not far from where the Indian and Atlantic oceans intersect. There was this intense moment where a great white was lured in by the bait and was thrashing at a tuna’s head about a foot away from my face! It was a serious Jaws moment.
Thanks for the interview, Vishay. Now get back to work and help us make more money!
- Eric Leichtenschlag, AdMob Developer Relations
- Vishay Nihalani, AdMob Mediation Product Manager