Using advanced date ranges in AdSense APIs


Using DFP App Events with the Google AdMob SDK
The next step is to have the application code listen for these app events. Here are the iOS and Android versions of this method, respectively:
// iOS - (void)adView:(DFPBannerView *)banner didReceiveAppEvent:(NSString *)name withInfo:(NSString *)info { NSLog(@"Received app event (%@, %@)", name, info); // Checking for a "color" event name with information being a color. if ([name isEqualToString:@"color"]) { if ([info isEqualToString:@"red"]) { self.view.backgroundColor = [UIColor redColor]; } else if ([info isEqualToString:@"green"]) { self.view.backgroundColor = [UIColor greenColor]; } } } // Android @Override public void onAppEvent(Ad ad, String name, String info) { String message = String.format("Received app event (%s, %s)", name, info); Log.d(LOG_TAG, message); if ("color".equals(name)) { LinearLayout layout = (LinearLayout) findViewById(R.id.mainLayout); if ("red".equals(info)) { layout.setBackgroundColor(Color.RED); } else if ("green".equals(info)) { layout.setBackgroundColor(Color.GREEN); } } }
Remember to register this callback on the banner view:
// iOS [bannerView_ setAppEventDelegate:self]; // Android adView.setAppEventListener(this);
That’s it! If you load this ad into your banner view, your application will change its background color to red when the ad is loaded, and green when the ad is clicked. This example can be extended to change the implementation of the app event listener or to fire app events at any point during the creative’s lifecycle.
Let us know on the forum if you have any questions about app events specifically or the Google AdMob SDK in general. You can also follow us on our plus page for AdMob-related updates.
Edit: Fixed plus page link.
- Eric Leichtenschlag, AdMob Team


Release Updates for DFA Developers


Impression share reporting changes


Sunsetting the AdWords API Sandbox. Introducing Test Accounts


Create Your Own Version of loadAndDisplayRequest:usingWindow:initialImage:


DoubleClick Ad Exchange Buyer: Upcoming SSL Requirement


Understanding AdWords API TargetingIdeaService and user interface numbers


A new API: DoubleClick Ad Exchange Seller REST API


AdWords API v201109 and v201109_1 sunset on October 26th, 2012


AdWords API v201209 launch - including shared budgets and more


Using OAuth2.0 authorization method with Ruby client libraries


DFA Reporting API Version 1.1 Released

