Anúncios de banner de tamanho fixo

Selecione a plataforma: Android iOS Flutter

O SDK dos anúncios para dispositivos móveis do Google aceita tamanhos de anúncio fixos para situações em que os anúncios de banners adaptativos não atendem às suas necessidades.

A tabela a seguir lista os tamanhos de banner padrão.

Tamanho em dp (L x A) Descrição Disponibilidade Constante AdSize
320 x 50 Banner Celulares e tablets GADAdSizeBanner
320 x 100 Banner grande Celulares e tablets GADAdSizeLargeBanner
300 x 250 Retângulo médio IAB Celulares e tablets GADAdSizeMediumRectangle
468 x 60 Banner em tamanho real IAB Tablets GADAdSizeFullBanner
728 x 90 Cabeçalho IAB Tablets GADAdSizeLeaderboard

Para definir um tamanho personalizado, use GADAdSizeFromCGSize:

Swift

let adSize = adSizeFor(cgSize: CGSize(width: 250, height: 250))

Objective-C

GADAdSize size = GADAdSizeFromCGSize(CGSizeMake(250, 250));

Exemplo de anúncios de banner de tamanho fixo

Swift Objective-C

Tamanho de anúncio personalizado

Além dos blocos de anúncios padrão, o Google Ad Manager permite veicular blocos de qualquer tamanho em um app. O tamanho do anúncio (largura, altura) definido para uma solicitação precisa corresponder às dimensões da visualização de anúncio (GAMBannerView) exibida no app. Para definir um tamanho personalizado, use GADAdSizeFromCGSize.

Swift

// Define custom GADAdSize of 250x250 for GAMBannerView.
let customAdSize = adSizeFor(cgSize: CGSize(width: 250, height: 250))
bannerView = GAMBannerView(adSize: customAdSize)

Objective-C

// Define custom GADAdSize of 250x250 for GAMBannerView
GADAdSize customAdSize = GADAdSizeFromCGSize(CGSizeMake(250, 250));
self.bannerView = [[GAMBannerView alloc] initWithAdSize:customAdSize];

Vários tamanhos de anúncio

O Ad Manager permite especificar vários tamanhos de anúncio que podem ser veiculados em um GAMBannerView. Para usar esse recurso, é necessário seguir três etapas:

  1. Na interface do Ad Manager, crie um item de linha segmentando o mesmo bloco de anúncios que está associado a criativos de tamanhos diferentes.

  2. No app, defina a propriedade validAdSizes em GAMBannerView:

    Swift

    // Define an optional array of GADAdSize to specify all valid sizes that are appropriate
    // for this slot. Never create your own GADAdSize directly. Use one of the
    // predefined standard ad sizes (such as GADAdSizeBanner), or create one using
    // the GADAdSizeFromCGSize method.
    //
    // Note: Ensure that the allocated GAMBannerView is defined with an ad size. Also note
    // that all desired sizes should be included in the validAdSizes array.
    bannerView.validAdSizes = [NSValueFromGADAdSize(AdSizeBanner),
        NSValueFromGADAdSize(AdSizeMediumRectangle),
        NSValueFromGADAdSize(adSizeFor(cgSize: CGSize(width: 120, height: 20)))]
    

    Objective-C

    // Define an optional array of GADAdSize to specify all valid sizes that are appropriate
    // for this slot. Never create your own GADAdSize directly. Use one of the
    // predefined standard ad sizes (such as GADAdSizeBanner), or create one using
    // the GADAdSizeFromCGSize method.
    //
    // Note: Ensure that the allocated GAMBannerView is defined with an ad size. Also note
    // that all desired sizes should be included in the validAdSizes array.
    self.bannerView.validAdSizes = @[
        NSValueFromGADAdSize(GADAdSizeBanner),
        NSValueFromGADAdSize(GADAdSizeMediumRectangle),
        NSValueFromGADAdSize(GADAdSizeFromCGSize(CGSizeMake(120, 20)))
    ];
    
  3. Implemente o método GADAdSizeDelegate para detectar uma alteração no tamanho do anúncio.

    Swift

    public func bannerView(_ bannerView: BannerView, willChangeAdSizeTo size: AdSize)
    

    Objective-C

    - (void)bannerView:(GAMBannerView *)view willChangeAdSizeTo:(GADAdSize)size;
    

    Lembre-se de definir o delegado antes de fazer a solicitação de um anúncio.

    Swift

    bannerView.adSizeDelegate = self
    

    Objective-C

    self.bannerView.adSizeDelegate = self;
    

Exemplo de vários tamanhos de anúncio

Swift Objective-C