स्थानीय टेम्प्लेट

नेटिव टेंप्लेट डाउनलोड करें

नेटिव विज्ञापनों का इस्तेमाल करके, विज्ञापनों को अपनी पसंद के मुताबिक बनाया जा सकता है. इससे, उपयोगकर्ताओं को बेहतर अनुभव मिलता है. बेहतर उपयोगकर्ता अनुभव यूज़र ऐक्टिविटी को बढ़ा सकते हैं और आपके पूरे फ़ायदा को बढ़ा सकते हैं.

नेटिव विज्ञापनों का ज़्यादा से ज़्यादा फ़ायदा पाने के लिए, अपने विज्ञापन लेआउट को स्टाइल देना ज़रूरी है, ताकि वे आपके ऐप्लिकेशन के स्वाभाविक एक्सटेंशन की तरह दिखें. इसे शुरू करने में आपकी मदद के लिए, हमने नेटिव टेंप्लेट बनाए हैं.

नेटिव टेंप्लेट, आपके नेटिव विज्ञापनों के लिए पूरे कोड वाले व्यू होते हैं. इन्हें तेज़ी से लागू करने और उनमें आसानी से बदलाव करने के लिए डिज़ाइन किया गया है. नेटिव टेंप्लेट की मदद से, अपने पहले नेटिव विज्ञापन को कुछ ही मिनटों में लागू किया जा सकता है. साथ ही, बहुत सारे कोड के बिना, फ़ोटो के लुक और स्टाइल को तेज़ी से अपनी पसंद के मुताबिक बनाया जा सकता है. इन टेंप्लेट को अपनी पसंद के हिसाब से कहीं भी रखा जा सकता है. जैसे, न्यूज़ फ़ीड में इस्तेमाल किए जाने वाले टेबलव्यू में, डायलॉग में या आपके ऐप्लिकेशन में किसी दूसरी जगह पर.

इस गाइड से आपको iOS ऐप्लिकेशन में नेटिव टेंप्लेट को डाउनलोड करने, शामिल करने, और इस्तेमाल करने का तरीका पता चलेगा. यह मान लिया जाता है कि आपने नेटिव विज्ञापन लोड करने के लिए SDK टूल का पहले ही सही से इस्तेमाल कर लिया है.

टेंप्लेट के साइज़

टेंप्लेट के दो साइज़ होते हैं: छोटा और मीडियम. हर टेंप्लेट एक क्लास के तौर पर दिखाया जाता है. ये क्लास GADTSmallTemplateView और GADTMediumTemplateView हैं. दोनों क्लास GADTTemplateView तक जाती हैं. दोनों टेंप्लेट का आसपेक्ट रेशियो (लंबाई-चौड़ाई का अनुपात) तय होता है, जो addHorizontalConstraintsToSuperviewWidth को कॉल करने पर ही अपने पैरंट व्यू की चौड़ाई को पूरा करने के लिए स्केल करेगा. अगर addHorizontalConstraintsToSuperviewWidth को कॉल नहीं किया जाता है, तो हर टेंप्लेट अपने डिफ़ॉल्ट साइज़ को रेंडर करेगा.

GADTSmallTemplateView

UICollectionView या UITableView सेल के लिए, छोटा टेंप्लेट सबसे अच्छा होता है. उदाहरण के लिए, इसका इस्तेमाल इन-फ़ीड विज्ञापनों के लिए या किसी भी ऐसी जगह पर किया जा सकता है जहां आपको पतले आयताकार विज्ञापन व्यू की ज़रूरत हो. इस टेंप्लेट का डिफ़ॉल्ट साइज़ 91 पॉइंट ऊंचा और 355 पॉइंट चौड़ा है.

GADTMediumTemplateView

मीडियम टेंप्लेट, 1/2 से 3/4 पेज के व्यू के लिए होता है. यह लैंडिंग या स्प्लैश पेजों के लिए अच्छा है. हालांकि, इसे UITableViews में भी शामिल किया जा सकता है. इस टेंप्लेट का डिफ़ॉल्ट साइज़ 370 पॉइंट ऊंचा और 355 पॉइंट चौड़ा है.

हमारे सभी टेंप्लेट, अपने-आप लेआउट सेट होने की सुविधा के साथ काम करते हैं. इसलिए, प्लेसमेंट के साथ प्रयोग करें. बेशक, आप अपनी ज़रूरतों के मुताबिक सोर्स कोड और xib फ़ाइलों को भी बदल सकते हैं.

नेटिव विज्ञापन टेंप्लेट इंस्टॉल करना

नेटिव टेंप्लेट इंस्टॉल करने के लिए, बस ज़िप को डाउनलोड करें और उसे अपने 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 you’d like, and don’t 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 फ़ाइल में व्यू का साइज़ बदला हो, लेकिन सब-क्लास की "सेटअप" तरीके में बनाए गए फ़्रेम के साइज़ में बदलाव न किया हो.
मैं इन टेंप्लेट को और ज़रूरत के मुताबिक कैसे बनाऊं?
ये टेंप्लेट सिर्फ़ xibs हैं, जिनमें जुड़े हुए व्यू ऑब्जेक्ट हैं, जैसे कि iOS डेवलपमेंट के दौरान इस्तेमाल किए जाने वाले दूसरे xib और कस्टम व्यू क्लास की तरह. अगर आपको अपने नेटिव विज्ञापन शुरू से बनाने हैं, तो हमारी नेटिव एडवांस गाइड देखें.
xib में सेट करने पर, मेरी स्टाइल अपडेट क्यों नहीं हो रही हैं?
फ़िलहाल, हम GADTTemplateView.m में सभी xib स्टाइल को डिफ़ॉल्ट स्टाइल डिक्शनरी से बदल देते हैं.

योगदान दें

हमने नेटिव टेंप्लेट बनाए हैं, ताकि आप नेटिव विज्ञापन जल्दी तैयार कर सकें. हमें खुशी है कि आपने नए टेंप्लेट या सुविधाएं जोड़ने के लिए, हमारे GitHub डेटा स्टोर में योगदान दिया. हमें पुल का अनुरोध भेजें और हम उस पर गौर करेंगे.