GoogleMobileAds Framework Reference

GADBannerView

@interface GADBannerView : UIView

A view that displays banner ads. See https://developers.google.com/admob/ios/banner to get started.

  • Initializes and returns a banner view with the specified ad size and origin relative to the banner’s superview.

    Declaration

    Swift

    init(adSize: GADAdSize, origin: CGPoint)

    Objective-C

    - (nonnull instancetype)initWithAdSize:(GADAdSize)adSize origin:(CGPoint)origin;
  • Initializes and returns a banner view with the specified ad size placed at its superview’s origin.

    Declaration

    Swift

    init(adSize: GADAdSize)

    Objective-C

    - (nonnull instancetype)initWithAdSize:(GADAdSize)adSize;
  • Required value created on the AdMob website. Create a new ad unit for every unique placement of an ad in your application. Set this to the ID assigned for this placement. Ad units are important for targeting and statistics.

    Example AdMob ad unit ID: @“ca-app-pub-0123456789012345/0123456789”

    Declaration

    Swift

    var adUnitID: String? { get set }

    Objective-C

    @property (nonatomic, copy, nullable) NSString *adUnitID;
  • Required reference to a root view controller that is used by the banner to present full screen content after the user interacts with the ad. The root view controller is most commonly the view controller displaying the banner.

    Declaration

    Swift

    @IBOutlet weak var rootViewController: UIViewController? { get set }

    Objective-C

    @property (nonatomic, weak, nullable) UIViewController *rootViewController;
  • Required to set this banner view to a proper size. Never create your own GADAdSize directly. Use one of the predefined standard ad sizes (such as kGADAdSizeBanner), or create one using the GADAdSizeFromCGSize method. If not using mediation, then changing the adSize after an ad has been shown will cause a new request (for an ad of the new size) to be sent. If using mediation, then a new request may not be sent.

    Declaration

    Swift

    var adSize: GADAdSize { get set }

    Objective-C

    @property (nonatomic) GADAdSize adSize;
  • Optional delegate object that receives state change notifications from this GADBannerView. Typically this is a UIViewController.

    Declaration

    Swift

    @IBOutlet weak var delegate: GADBannerViewDelegate? { get set }

    Objective-C

    @property (nonatomic, weak, nullable) id<GADBannerViewDelegate> delegate;
  • Optional delegate that is notified when creatives cause the banner to change size.

    Declaration

    Swift

    @IBOutlet weak var adSizeDelegate: GADAdSizeDelegate? { get set }

    Objective-C

    @property (nonatomic, weak, nullable) id<GADAdSizeDelegate> adSizeDelegate;
  • Requests an ad. The request object supplies targeting information.

    Declaration

    Swift

    func load(_ request: GADRequest?)

    Objective-C

    - (void)loadRequest:(nullable GADRequest *)request;
  • A Boolean value that determines whether autoloading of ads in the receiver is enabled. If enabled, you do not need to call the loadRequest: method to load ads.

    Declaration

    Swift

    var isAutoloadEnabled: Bool { get set }

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite,
              getter=isAutoloadEnabled) BOOL autoloadEnabled;
  • Information about the ad response that returned the current ad or an error. Nil until the first ad request succeeds or fails.

    Declaration

    Swift

    var responseInfo: GADResponseInfo? { get }

    Objective-C

    @property (nonatomic, readonly, nullable) GADResponseInfo *responseInfo;
  • Called when ad is estimated to have earned money. Available for allowlisted accounts only.

    Declaration

    Swift

    var paidEventHandler: GADPaidEventHandler? { get set }

    Objective-C

    @property (nonatomic, copy, nullable) GADPaidEventHandler paidEventHandler;