- (void)applicationDidBecomeActive:(UIApplication *)application
{
if (!self.window.rootViewController.modalViewController) {
GADRequest *request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects:
GAD_SIMULATOR_ID, // Simulator
nil];
GADInterstitial *interstitial = [[GADInterstitial alloc] init];
interstitial.adUnitID = @"some_ad_unit_id";
interstitial.delegate = self;
UIImage *splashImage = nil;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// first try orientation-specific launch images
if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown) {
splashImage = [UIImage imageNamed:@"Default-PortraitUpsideDown.png"];
} else if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft) {
splashImage = [UIImage imageNamed:@"Default-LandscapeLeft.png"];
} else if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight) {
splashImage = [UIImage imageNamed:@"Default-LandscapeRight.png"];
}
// if there wasn't found a orientation-specific launch-image
// try the ones for only Portrait/Landscape
if (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])) {
splashImage = [UIImage imageNamed:@"Default-Portrait.png"];
} else {
splashImage = [UIImage imageNamed:@"Default-Landscape.png"];
}
}
// iPhone, or still no image found on iPad -> use Default.png
if (!splashImage) {
splashImage = [UIImage imageNamed:@"Default.png"];
}
[interstitial loadAndDisplayRequest:request usingWindow:self.window initialImage:splashImage];
}
}