Introducing the Mobile Sites certification, for web developers


Native Express Video


Mobile Ads Garage #3: Banner ad best practices


Sunset of MobileAd and MobileImageAd Ad Types


AdWords API: Changes to how we report mobile click-to-call data


Build an app to win awesome Google prizes in The AdMob Student App Challenge


Upgrade to the new Google Mobile Ads SDK for Android


Achievement Unlocked: monetizing online games with TrueView and AdX


Customizing Your AdMob Mediation Ad Requests


New Mobile Ads Showcase App puts the best of mobile ads in agencies’ hands


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


Create Your Own Version of loadAndDisplayRequest:usingWindow:initialImage:

