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

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

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

גודל ב-dp (WxH) תיאור זמינות קבוע של גודל המודעה
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 Objective-C

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

בנוסף ליחידות המודעות הרגילות, 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