Get Started

This guide is intended for publishers who want to use AdMob to monetize an iOS app that's built with Firebase. If you don't plan to include Firebase in your app, see the standalone AdMob version of this guide instead.

Importing and initializing the Google Mobile Ads SDK is the first step toward displaying AdMob ads and earning revenue. Once that's done, you can choose an ad format (such as native or rewarded video) and get a detailed set of steps for implementing it.

Prerequisites

  1. Install the Firebase SDK.
  2. Create an AdMob account and register an app.
  3. Link the app to a Firebase project.

Import the Mobile Ads SDK

Add the dependency for the Mobile Ads SDK to your project's podfile:

pod 'Firebase/AdMob'

Then from the command line run:

pod install --repo-update

Initialize mobile ads

Before loading ads, apps should initialize the Mobile Ads SDK by calling the configureWithApplicationID: class method in GADMobileAds, and passing it their AdMob App ID. This only needs to be done once, ideally at app launch. You can find your app's App ID in the AdMob UI.

Here's an example of how to call configureWithApplicationID: in your AppDelegate:

Swift

import Firebase
…

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

  var window: UIWindow?

  func application(_ application: UIApplication,
      didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    // Use Firebase library to configure APIs.
    FirebaseApp.configure()

    // Initialize the Google Mobile Ads SDK.
    GADMobileAds.configure(withApplicationID: "YOUR_ADMOB_APP_ID")

    return true
  }

}

Objective-C

@import Firebase;
…

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  // Use Firebase library to configure APIs.
  [FIRApp configure];
  // Initialize the Google Mobile Ads SDK.
  [GADMobileAds configureWithApplicationID:@"YOUR_ADMOB_APP_ID"];
  return YES;
}

@end

If you haven't created an AdMob account and registered an app yet, now's a great time to do so. If you're just looking to experiment with the SDK in a Hello World app, though, you can use this App ID to initialize the SDK: ca-app-pub-3940256099942544~1458002511.

Choose an ad format

The Mobile Ads SDK is now imported and initialized, and you're ready to implement an ad. AdMob offers a number of different ad formats, so you can choose the one that best fits your app's user experience.

Banner ads are rectangular image or text ads that occupy a spot within an app's layout. They stay on screen while users are interacting with the app, and can refresh automatically after a certain period of time. If you're new to mobile advertising, they're a great place to start.

Implement a Banner

Interstitial

Interstitials are full-screen ads that cover the interface of an app until closed by the user. They're best used at natural pauses in the flow of an app's execution, such as in between levels of a game or just after completing a task.

Implement an Interstitial

Native

Native is a component-based ad format that gives you the freedom to customize the way assets like headlines and calls to action are presented in their apps. By choosing fonts, colors, and other details for yourself, you can create natural, unobtrusive ad presentations that can add to a rich user experience.

AdMob offers two different ways to implement native ads: Native Ads Express and Native Ads Advanced. Native Ads Express has been designed to make getting on board with native ads as easy as possible, and it's a great choice if you are new to the format. Native Ads Advanced has been designed to maximize the amount of freedom you have in creating your presentations. It's currently in a closed beta with a limited group of publishers.

Implement Native Ads Express Implement Native Ads Advanced

Rewarded Video

Rewarded video ads are full screen video ads that users have the option of watching in full in exchange for in-app rewards.

Implement Rewarded Video

Send feedback about...

Need help? Visit our support page.