Get Started

Integrating Universal Apps


When setting up a universal application (an app that will work on both phones and tablets) you will have to conditionally fire two different ad units.

  • Create a 320×50 ad unit and a 728×90 ad unit.
  • Detect the device type and appropriately use the right ad unit IDs in the MoPub ad call.
  • Use the following code: obj-c if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { mopubViewLandscape = [[MPAdView alloc] initWithAdUnitId:MOPUB_IPHONE_BANNER_ID size:MOPUB_BANNER_SIZE]; } else { mopubViewLandscape = [[MPAdView alloc] initWithAdUnitId:MOPUB_IPAD_BANNER_ID size:MOPUB_LEADERBOARD_SIZE]; }
  • Make sure you also conditionally set the right size for the specific ad unit.
  • If you’re on iOS, use the following code: obj-c -(void)adViewDidLoadAd:(MPAdView *)view { CGSize size = [view adContentViewSize]; CGRect newFrame = view.frame; newFrame.size = size; newFrame.origin.x = (self.view.bounds.size.width - size.width) / 2; view.frame = newFrame; }