เทมเพลตเนทีฟ

เลือกแพลตฟอร์ม: Android iOS Flutter

ดาวน์โหลดเทมเพลตโฆษณาเนทีฟ

การใช้โฆษณาเนทีฟช่วยให้คุณปรับแต่งโฆษณาได้ ซึ่งจะส่งผลให้ผู้ใช้ได้รับประสบการณ์ การใช้งานที่ดีขึ้น ประสบการณ์ของผู้ใช้ที่ดีขึ้นจะช่วยเพิ่มการมีส่วนร่วมและปรับปรุงผลตอบแทนโดยรวม

เพื่อให้ได้รับประโยชน์สูงสุดจากโฆษณาเนทีฟ คุณควรจัดรูปแบบเลย์เอาต์โฆษณา เพื่อให้ดูเหมือนเป็นส่วนขยายตามธรรมชาติของแอป เราได้สร้างเทมเพลตโฆษณาเนทีฟเพื่อช่วยคุณเริ่มต้นใช้งาน

เทมเพลตเนทีฟคือมุมมองที่สมบูรณ์ของโค้ดสำหรับโฆษณาเนทีฟ ซึ่งออกแบบมาเพื่อการติดตั้งใช้งานที่รวดเร็ว และการแก้ไขที่ง่ายดาย เทมเพลตโฆษณาเนทีฟช่วยให้คุณติดตั้งใช้งาน โฆษณาเนทีฟแรกได้ในเวลาไม่กี่นาที และปรับแต่ง รูปลักษณ์ได้อย่างรวดเร็วโดยไม่ต้องใช้โค้ดมากนัก คุณวางเทมเพลตเหล่านี้ได้ทุกที่ที่ต้องการ เช่น ใน TableView ที่ใช้ในฟีดข่าว ในกล่องโต้ตอบ หรือที่อื่นๆ ในแอป

คู่มือนี้จะแสดงวิธีดาวน์โหลด รวม และใช้เทมเพลตเนทีฟในแอป iOS โดยจะถือว่าคุณใช้ SDK เพื่อโหลดโฆษณาเนทีฟได้สำเร็จแล้ว

ขนาดเทมเพลต

เทมเพลตมี 2 ขนาด ได้แก่ เล็กและกลาง โดยแต่ละเทมเพลตจะแสดงด้วยคลาส คลาสคือ GADTSmallTemplateView และ GADTMediumTemplateView ทั้ง 2 คลาสจะขยายเวลาGADTTemplateView เทมเพลตทั้ง 2 แบบมีสัดส่วนภาพคงที่ ซึ่งจะปรับขนาดให้พอดีกับความกว้างของ มุมมองหลักก็ต่อเมื่อคุณเรียกใช้ addHorizontalConstraintsToSuperviewWidth หากไม่เรียกใช้ addHorizontalConstraintsToSuperviewWidth เทมเพลตแต่ละรายการ จะแสดงผลขนาดเริ่มต้น

GADTSmallTemplateView

เทมเพลตขนาดเล็กเหมาะสำหรับเซลล์ UICollectionView หรือ UITableView เช่น คุณอาจใช้กับโฆษณาในฟีด หรือที่ใดก็ตามที่ต้องการมุมมองโฆษณาสี่เหลี่ยมผืนผ้า บางๆ ขนาดเริ่มต้นของเทมเพลตนี้คือสูง 91 พอยต์และกว้าง 355 พอยต์

GADTMediumTemplateView

เทมเพลตสื่อมีไว้สำหรับการดูหน้าเว็บ 1/2 ถึง 3/4 หน้า ซึ่งเหมาะสำหรับหน้า Landing Page หรือหน้า Splash แต่ก็สามารถรวมไว้ใน UITableViews ได้เช่นกัน ขนาดเริ่มต้นของเทมเพลตนี้คือสูง 370 พอยต์และกว้าง 355 พอยต์

เทมเพลตทั้งหมดรองรับการจัดวางอัตโนมัติ คุณจึงทดลองใช้ ตําแหน่งได้อย่างอิสระ แน่นอนว่าคุณยังเปลี่ยนซอร์สโค้ดและไฟล์ xib เพื่อให้ตรงกับความต้องการได้ด้วย

การติดตั้งเทมเพลตโฆษณาเนทีฟ

หากต้องการติดตั้งเทมเพลตเนทีฟ เพียงดาวน์โหลดไฟล์ ZIP แล้วลากไปยังโปรเจ็กต์ Xcode อย่าลืมเลือกคัดลอกรายการหากจำเป็น

การใช้เทมเพลตโฆษณาเนทีฟ

เมื่อเพิ่มโฟลเดอร์ลงในโปรเจ็กต์และรวมคลาสที่เกี่ยวข้องไว้ในไฟล์แล้ว ให้ทำตามสูตรนี้เพื่อใช้เทมเพลต โปรดทราบว่าวิธีเดียว ในการเปลี่ยนพร็อพเพอร์ตี้แบบอักษรและสไตล์คือการใช้พจนานุกรมสไตล์ ซึ่งปัจจุบันเรา จะลบล้างสไตล์ใดๆ ที่ตั้งค่าไว้ใน xib เอง

Objective-C

/// Step 1: Import the templates that you need.
#import "NativeTemplates/GADTSmallTemplateView.h"
#import "NativeTemplates/GADTTemplateView.h"
...

// STEP 2: Initialize your template view object.
GADTSmallTemplateView *templateView =
    [[NSBundle mainBundle] loadNibNamed:@"GADTSmallTemplateView" owner:nil options:nil]
      .firstObject;

// STEP 3: Template views are just GADNativeAdViews.
_nativeAdView = templateView;
nativeAd.delegate = self;

// STEP 4: Add your template as a subview of whichever view you'd like.
// This must be done before calling addHorizontalConstraintsToSuperviewWidth.
// Please note: Our template objects are subclasses of GADNativeAdView so
// you can insert them into whatever type of view youd like, and dont need to
// create your own.
[self.view addSubview:templateView];

// STEP 5 (Optional): Create your styles dictionary. Set your styles dictionary
// on the template property. A default dictionary is created for you if you do
// not set this. Note - templates do not currently respect style changes in the
// xib.

NSString *myBlueColor = @"#5C84F0";
NSDictionary *styles = @{
    GADTNativeTemplateStyleKeyCallToActionFont : [UIFont systemFontOfSize:15.0],
    GADTNativeTemplateStyleKeyCallToActionFontColor : UIColor.whiteColor,
    GADTNativeTemplateStyleKeyCallToActionBackgroundColor :
        [GADTTemplateView colorFromHexString:myBlueColor],
    GADTNativeTemplateStyleKeySecondaryFont : [UIFont systemFontOfSize:15.0],
    GADTNativeTemplateStyleKeySecondaryFontColor : UIColor.grayColor,
    GADTNativeTemplateStyleKeySecondaryBackgroundColor : UIColor.whiteColor,
    GADTNativeTemplateStyleKeyPrimaryFont : [UIFont systemFontOfSize:15.0],
    GADTNativeTemplateStyleKeyPrimaryFontColor : UIColor.blackColor,
    GADTNativeTemplateStyleKeyPrimaryBackgroundColor : UIColor.whiteColor,
    GADTNativeTemplateStyleKeyTertiaryFont : [UIFont systemFontOfSize:15.0],
    GADTNativeTemplateStyleKeyTertiaryFontColor : UIColor.grayColor,
    GADTNativeTemplateStyleKeyTertiaryBackgroundColor : UIColor.whiteColor,
    GADTNativeTemplateStyleKeyMainBackgroundColor : UIColor.whiteColor,
    GADTNativeTemplateStyleKeyCornerRadius : [NSNumber numberWithFloat:7.0],
};

templateView.styles = styles;

// STEP 6: Set the ad for your template to render.
templateView.nativeAd = nativeAd;

// STEP 7 (Optional): If you'd like your template view to span the width of your
// superview call this method.
[templateView addHorizontalConstraintsToSuperviewWidth];
[templateView addVerticalCenterConstraintToSuperview];

คีย์พจนานุกรมสไตล์

วิธีที่เร็วที่สุดในการปรับแต่งเทมเพลตคือการสร้างพจนานุกรมที่มีคีย์ต่อไปนี้

Objective-C

/// Call to action font. Expects a UIFont.
GADTNativeTemplateStyleKeyCallToActionFont

/// Call to action font color. Expects a UIColor.
GADTNativeTemplateStyleKeyCallToActionFontColor;

/// Call to action background color. Expects a UIColor.
GADTNativeTemplateStyleKeyCallToActionBackgroundColor;

/// The font, font color and background color for the first row of text in the
/// template.

/// All templates have a primary text area which is populated by the native ad's
/// headline.

/// Primary text font. Expects a UIFont.
GADTNativeTemplateStyleKeyPrimaryFont;

/// Primary text font color. Expects a UIFont.
GADTNativeTemplateStyleKeyPrimaryFontColor;

/// Primary text background color. Expects a UIColor.
GADTNativeTemplateStyleKeyPrimaryBackgroundColor;

/// The font, font color and background color for the second row of text in the
/// template.

/// All templates have a secondary text area which is populated either by the
/// body of the ad, or by the rating of the app.

/// Secondary text font. Expects a UIFont.
GADTNativeTemplateStyleKeySecondaryFont;

/// Secondary text font color. Expects a UIColor.
GADTNativeTemplateStyleKeySecondaryFontColor;

/// Secondary text background color. Expects a UIColor.
GADTNativeTemplateStyleKeySecondaryBackgroundColor;

/// The font, font color and background color for the third row of text in the
/// template. The third row is used to display store name or the default
/// tertiary text.

/// Tertiary text font. Expects a UIFont.
GADTNativeTemplateStyleKeyTertiaryFont;

/// Tertiary text font color. Expects a UIColor.
GADTNativeTemplateStyleKeyTertiaryFontColor;

/// Tertiary text background color. Expects a UIColor.
GADTNativeTemplateStyleKeyTertiaryBackgroundColor;

/// The background color for the bulk of the ad. Expects a UIColor.
GADTNativeTemplateStyleKeyMainBackgroundColor;

/// The corner rounding radius for the icon view and call to action. Expects an
/// NSNumber.
GADTNativeTemplateStyleKeyCornerRadius;

คำถามที่พบบ่อย

เหตุใดฉันจึงได้รับข้อยกเว้นเมื่อพยายามสร้างออบเจ็กต์เทมเพลต
ปัญหานี้อาจเกิดขึ้นหากคุณเปลี่ยนขนาดของมุมมองในไฟล์ XIB แต่ ไม่ได้เปลี่ยนขนาดของเฟรมที่สร้างขึ้นในเมธอด "setup" ของ คลาสย่อย
ฉันจะปรับแต่งเทมเพลตเหล่านี้เพิ่มเติมได้อย่างไร
เทมเพลตเหล่านี้เป็นเพียง XIB ที่มีออบเจ็กต์มุมมองที่เชื่อมโยง เช่นเดียวกับ XIB อื่นๆ และคลาสมุมมองที่กำหนดเองที่คุณอาจคุ้นเคยจากการพัฒนา iOS หากต้องการสร้างโฆษณาเนทีฟตั้งแต่ต้น โปรดดูคู่มือเนทีฟขั้นสูง
เหตุใดรูปแบบของฉันจึงไม่อัปเดตเมื่อตั้งค่าใน xib
ปัจจุบันเราลบล้างรูปแบบ xib ทั้งหมดด้วยพจนานุกรมรูปแบบเริ่มต้นใน GADTTemplateView.m

มีส่วนร่วม

เราได้สร้างเทมเพลตโฆษณาเนทีฟเพื่อช่วยให้คุณพัฒนาโฆษณาเนทีฟได้อย่างรวดเร็ว เรายินดีเป็นอย่างยิ่งหากคุณจะร่วมให้ข้อมูลในที่เก็บGitHub เพื่อเพิ่มเทมเพลตหรือฟีเจอร์ใหม่ๆ ส่งคำขอดึงข้อมูลมาให้เรา แล้วเราจะตรวจสอบ