מודעות באנר בגודל קבוע

Google Mobile Ads SDK תומך בגדלים קבועים של מודעות במצבים שבהם מודעות באנר מותאמות לא עונות על הצרכים שלך.

בטבלה הבאה מפורטים הגדלים הרגילים של מודעות באנר.

גודל ב-dp (WxH) תיאור זמינות קבוע AdSize
320x50 כרזה טלפונים וטאבלטים GADAdSizeBanner
320x100 מודעת באנר גדולה טלפונים וטאבלטים GADAdSizeLargeBanner
300x250 מלבן בינוני ב-IAB טלפונים וטאבלטים GADAdSizeMediumRectangle
468x60 מודעת באנר בגודל מלא של IAB טאבלטים GADAdSizeFullBanner
728x90 לוח הישגי השחקנים המובילים של IAB טאבלטים GADAdSizeLeaderboard

כדי להגדיר גודל מותאם אישית של מודעת באנר, מגדירים את הגודל באמצעות GADAdSizeFromCGSize:

Swift

let adSize = GADAdSizeFromCGSize(CGSize(width: 250, height: 250))

Objective-C

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

דוגמה למודעות באנר בגודל קבוע

Swift יעד-ג

גודל מודעה מותאם אישית

בנוסף ליחידות המודעות הרגילות, Google Ad Manager מאפשר להציג בתוך אפליקציה יחידת מודעות בכל גודל. גודל המודעה (רוחב, גובה) שמוגדר לבקשה להצגת מודעה צריך להתאים למידות של תצוגת המודעה (GAMBannerView) שמוצגת באפליקציה. כדי להגדיר גודל מותאם אישית, צריך להשתמש ב-GADAdSizeFromCGSize.

Swift

// Define custom GADAdSize of 250x250 for GAMBannerView.
let customAdSize = GADAdSizeFromCGSize(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];

גדלים מרובים של מודעות

ב-Ad Manager אפשר לציין כמה גדלים של מודעות שיכולים להיות כשירים להצגה ב-GAMBannerView. יש שלושה שלבים לשימוש בתכונה הזו:

  1. בממשק המשתמש של Ad Manager, יוצרים פריט שמטרגט את אותה יחידת מודעות שמשויכת לקריאייטיבים בגדלים שונים.

  2. באפליקציה שלך, צריך להגדיר את הנכס validAdSizes כ-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(GADAdSizeBanner),
        NSValueFromGADAdSize(GADAdSizeMediumRectangle),
        NSValueFromGADAdSize(GADAdSizeFromCGSize(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. הטמעת השיטה GADAdSizeDelegate כדי לזהות שינוי בגודל המודעה.

    Swift

    public func bannerView(_ bannerView: GADBannerView, willChangeAdSizeTo size: GADAdSize)
    

    Objective-C

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

    חשוב לזכור להגדיר את המשתמש שהענקת לו גישה לפני שליחת הבקשה להצגת מודעה.

    Swift

    bannerView.adSizeDelegate = self
    

    Objective-C

    self.bannerView.adSizeDelegate = self;
    

דוגמה למספר גדלים של מודעות

Swift Objective-C