تبلیغات بنری با اندازه ثابت

Google Mobile Ads SDK از اندازه‌های ثابت تبلیغات برای موقعیت‌هایی پشتیبانی می‌کند که تبلیغات بنرهای تطبیقی ​​نیازهای شما را برآورده نمی‌کنند.

جدول زیر اندازه استاندارد بنرها را فهرست می کند.

اندازه بر حسب dp (WxH) شرح دسترسی AdSize ثابت
320x50 بنر گوشی و تبلت GADAdSizeBanner
320x100 بنر بزرگ گوشی و تبلت GADAdSizeLargeBanner
300x250 مستطیل متوسط ​​IAB گوشی و تبلت GADAdSizeMediumRectangle
468x60 بنر سایز کامل IAB قرص GADAdSizeFullBanner
728x90 تابلوی امتیازات IAB قرص GADAdSizeLeaderboard

برای تعریف اندازه بنر سفارشی، اندازه خود را با استفاده از GADAdSizeFromCGSize تنظیم کنید:

سریع

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

هدف-C

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

نمونه تبلیغات بنری با اندازه ثابت

Swift Objective-C

اندازه تبلیغ سفارشی

علاوه بر واحدهای تبلیغاتی استاندارد، Google Ad Manager به شما امکان می دهد هر واحد تبلیغاتی با اندازه را در یک برنامه ارائه دهید. اندازه تبلیغ (عرض، ارتفاع) تعریف شده برای درخواست تبلیغ باید با ابعاد نمای تبلیغ ( GAMBannerView ) نمایش داده شده در برنامه مطابقت داشته باشد. برای تنظیم اندازه سفارشی، از GADAdSizeFromCGSize استفاده کنید.

سریع

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

هدف-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 تنظیم کنید:

    سریع

    // 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)))]
    

    هدف-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 را اجرا کنید.

    سریع

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

    هدف-C

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

    به یاد داشته باشید که قبل از درخواست آگهی، نماینده را تنظیم کنید.

    سریع

    bannerView.adSizeDelegate = self
    

    هدف-C

    self.bannerView.adSizeDelegate = self;
    

مثال چند اندازه تبلیغات

Swift Objective-C