iPhone X বিজ্ঞাপন রেন্ডারিং

এই নির্দেশিকাটি iPhone X-এ সঠিকভাবে বিজ্ঞাপন রেন্ডার করার জন্য আপনার অ্যাপগুলিকে কীভাবে কোড করতে হয় তার সর্বোত্তম অনুশীলনগুলি প্রদর্শন করে৷

পূর্বশর্ত

গোলাকার কোণ, সেন্সর হাউজিং এবং হোম ইন্ডিকেটর দ্বারা অস্পষ্ট হওয়া এড়াতে ব্যানার বিজ্ঞাপনগুলি অবশ্যই "নিরাপদ এলাকায়" স্থাপন করতে হবে। এই পৃষ্ঠায় আপনি নিরাপদ এলাকার উপরে বা নীচে একটি ব্যানার স্থাপন করার জন্য কীভাবে সীমাবদ্ধতা যুক্ত করবেন তার উদাহরণ পাবেন।

স্টোরিবোর্ড/ইন্টারফেস বিল্ডার

যদি আপনার অ্যাপ ইন্টারফেস বিল্ডার ব্যবহার করে, প্রথমে নিশ্চিত করুন যে আপনি নিরাপদ এলাকা লেআউট গাইড সক্রিয় করেছেন। এটি করার জন্য আপনাকে Xcode 9+ চালাতে হবে এবং iOS 9+ টার্গেট করতে হবে।

আপনার ইন্টারফেস বিল্ডার ফাইল খুলুন এবং আপনার ভিউ কন্ট্রোলার দৃশ্যে ক্লিক করুন। আপনি ডানদিকে ইন্টারফেস বিল্ডার ডকুমেন্ট অপশন দেখতে পাবেন। নিরাপদ এলাকা লেআউট গাইড ব্যবহার করুন এবং নিশ্চিত করুন যে আপনি সর্বনিম্ন হিসাবে iOS 9.0 এবং পরবর্তীতে তৈরি করছেন।

আমরা আপনাকে প্রস্থ এবং উচ্চতার সীমাবদ্ধতা ব্যবহার করে ব্যানারটিকে প্রয়োজনীয় আকারে সীমাবদ্ধ করার পরামর্শ দিই।

এখন আপনি GADBannerView এর শীর্ষ সম্পত্তিটিকে নিরাপদ এলাকার শীর্ষে সীমাবদ্ধ করে নিরাপদ এলাকার শীর্ষে ব্যানারটি সারিবদ্ধ করতে পারেন:

একইভাবে, আপনি নিরাপদ এলাকার নীচে GADBannerView এর নীচের সম্পত্তিকে সীমাবদ্ধ করে ব্যানারটিকে নিরাপদ এলাকার নীচে সারিবদ্ধ করতে পারেন:

আপনার সীমাবদ্ধতাগুলি এখন নীচের স্ক্রিনশটের মতো দেখতে হবে (আকার/পজিশনিং পরিবর্তিত হতে পারে):

ভিউ কন্ট্রোলার

এখানে একটি সাধারণ ভিউ কন্ট্রোলার কোড স্নিপেট রয়েছে যা উপরের স্টোরিবোর্ডে কনফিগার করা GADBannerView এ একটি ব্যানার দেখানোর জন্য ন্যূনতম প্রয়োজনীয় কাজ করে:

সুইফট

class ViewController: UIViewController {

  /// The banner view.
  @IBOutlet var bannerView: GADBannerView!

  override func viewDidLoad() {
    super.viewDidLoad()
    // Replace this ad unit ID with your own ad unit ID.
    bannerView.adUnitID = "ca-app-pub-3940256099942544/2934735716"
    bannerView.rootViewController = self
    bannerView.load(GADRequest())
  }

}

উদ্দেশ্য গ

@interface ViewController()

@property(nonatomic, strong) IBOutlet GADBannerView *bannerView;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  // Replace this ad unit ID with your own ad unit ID.
  self.bannerView.adUnitID = @"ca-app-pub-3940256099942544/2934735716";
  self.bannerView.rootViewController = self;
  GADRequest *request = [GADRequest request];
  [self.bannerView loadRequest:request];
}

নিরাপদ এলাকার প্রান্তে ব্যানার সারিবদ্ধ করা

আপনি যদি একটি বাম- বা ডান-সারিবদ্ধ ব্যানার পেতে চান, তবে ব্যানারের বাম/ডান প্রান্তটিকে নিরাপদ এলাকার বাম/ডান প্রান্তে সীমাবদ্ধ করুন এবং তত্ত্বাবধানের বাম/ডান প্রান্তে নয়।

আপনার যদি সেফ এরিয়া লেআউট গাইড ব্যবহার করা থাকে, তাহলে ইন্টারফেস বিল্ডার ডিফল্টভাবে ভিউতে সীমাবদ্ধতা যোগ করার সময় নিরাপদ এলাকা প্রান্ত ব্যবহার করবে।

প্রোগ্রাম্যাটিক

যদি আপনার অ্যাপটি প্রোগ্রামগতভাবে ব্যানার বিজ্ঞাপন তৈরি করে, আপনি সীমাবদ্ধতা সংজ্ঞায়িত করতে পারেন এবং ব্যানার বিজ্ঞাপনটিকে কোডে অবস্থান করতে পারেন। এই উদাহরণটি দেখায় কিভাবে একটি ব্যানারকে নিরাপদ এলাকার নীচে অনুভূমিকভাবে কেন্দ্রীভূত করতে বাধা দিতে হয়:

সুইফট

class ViewController: UIViewController {

  var bannerView: GADBannerView!

  override func viewDidLoad() {
    super.viewDidLoad()

    // Instantiate the banner view with your desired banner size.
    bannerView = GADBannerView(adSize: GADAdSizeBanner)
    addBannerViewToView(bannerView)
    bannerView.rootViewController = self
    // Set the ad unit ID to your own ad unit ID here.
    bannerView.adUnitID = "ca-app-pub-3940256099942544/2934735716"
    bannerView.load(GADRequest())
  }

  func addBannerViewToView(_ bannerView: UIView) {
    bannerView.translatesAutoresizingMaskIntoConstraints = false
    view.addSubview(bannerView)
    if #available(iOS 11.0, *) {
      positionBannerAtBottomOfSafeArea(bannerView)
    }
    else {
      positionBannerAtBottomOfView(bannerView)
    }
  }

  @available (iOS 11, *)
  func positionBannerAtBottomOfSafeArea(_ bannerView: UIView) {
    // Position the banner. Stick it to the bottom of the Safe Area.
    // Centered horizontally.
    let guide: UILayoutGuide = view.safeAreaLayoutGuide

    NSLayoutConstraint.activate(
      [bannerView.centerXAnchor.constraint(equalTo: guide.centerXAnchor),
       bannerView.bottomAnchor.constraint(equalTo: guide.bottomAnchor)]
    )
  }

  func positionBannerAtBottomOfView(_ bannerView: UIView) {
    // Center the banner horizontally.
    view.addConstraint(NSLayoutConstraint(item: bannerView,
                                          attribute: .centerX,
                                          relatedBy: .equal,
                                          toItem: view,
                                          attribute: .centerX,
                                          multiplier: 1,
                                          constant: 0))
    // Lock the banner to the top of the bottom layout guide.
    view.addConstraint(NSLayoutConstraint(item: bannerView,
                                          attribute: .bottom,
                                          relatedBy: .equal,
                                          toItem: self.bottomLayoutGuide,
                                          attribute: .top,
                                          multiplier: 1,
                                          constant: 0))
  }

}

উদ্দেশ্য গ

@interface ViewController()

@property(nonatomic, strong) GADBannerView *bannerView;

@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  // Instantiate the banner view with your desired banner size.
  self.bannerView = [[GADBannerView alloc] initWithAdSize:GADAdSizeBanner];
  [self addBannerViewToView:self.bannerView];

  // Replace this ad unit ID with your own ad unit ID.
  self.bannerView.adUnitID = @"ca-app-pub-3940256099942544/2934735716";
  self.bannerView.rootViewController = self;
  GADRequest *request = [GADRequest request];
  [self.bannerView loadRequest:request];
}

#pragma mark - view positioning

-(void)addBannerViewToView:(UIView *_Nonnull)bannerView {
  self.bannerView.translatesAutoresizingMaskIntoConstraints = NO;
  [self.view addSubview:self.bannerView];
  if (@available(ios 11.0, *)) {
    [self positionBannerViewAtBottomOfSafeArea:bannerView];
  } else {
    [self positionBannerViewAtBottomOfView:bannerView];
  }
}

- (void)positionBannerViewAtBottomOfSafeArea:(UIView *_Nonnull)bannerView NS_AVAILABLE_IOS(11.0) {
  // Position the banner. Stick it to the bottom of the Safe Area.
  // Centered horizontally.
  UILayoutGuide *guide = self.view.safeAreaLayoutGuide;
  [NSLayoutConstraint activateConstraints:@[
    [bannerView.centerXAnchor constraintEqualToAnchor:guide.centerXAnchor],
    [bannerView.bottomAnchor constraintEqualToAnchor:guide.bottomAnchor]
  ]];
}

- (void)positionBannerViewAtBottomOfView:(UIView *_Nonnull)bannerView {
  [self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView
                                                        attribute:NSLayoutAttributeCenterX
                                                        relatedBy:NSLayoutRelationEqual
                                                           toItem:self.view
                                                        attribute:NSLayoutAttributeCenterX
                                                       multiplier:1
                                                         constant:0]];
  [self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView
                                                        attribute:NSLayoutAttributeBottom
                                                        relatedBy:NSLayoutRelationEqual
                                                           toItem:self.bottomLayoutGuide
                                                        attribute:NSLayoutAttributeTop
                                                       multiplier:1
                                                         constant:0]];
}

@end

উপরের কৌশলগুলি ব্যবহার করা বৈশিষ্ট্য এবং অ্যাঙ্করগুলিকে সংশোধন করে নিরাপদ এলাকার শীর্ষে সীমাবদ্ধ করার জন্য সহজেই ব্যবহার করা যেতে পারে।

স্মার্ট ব্যানার

আপনি যদি স্মার্ট ব্যানার ব্যবহার করেন, বিশেষ করে ল্যান্ডস্কেপে, আমরা সুপারিশ করি যে আপনি ব্যানারের প্রান্তগুলিকে নিরাপদ এলাকার বাম এবং ডান প্রান্তে সারিবদ্ধ করার জন্য সীমাবদ্ধতাগুলি ব্যবহার করুন৷

ইন্টারফেস বিল্ডারে, উপরে বর্ণিত হিসাবে নিরাপদ এলাকা লেআউট গাইড বিকল্পটি ব্যবহার করে এটিকে iOS 9-এ সমর্থন করা হয়।

কোডে, আপনি আপনার প্রান্তের সীমাবদ্ধতাগুলিকে নিরাপদ এলাকা লেআউট গাইড যেখানে উপলব্ধ আছে তার সাথে সম্পর্কিত করা উচিত। এখানে একটি কোড স্নিপেট রয়েছে যা ভিউতে একটি ব্যানার ভিউ যোগ করে এবং ভিউয়ের নীচে, পূর্ণ-প্রস্থে সীমাবদ্ধ করে:

সুইফট

func addBannerViewToView(_ bannerView: GADBannerView) {
  bannerView.translatesAutoresizingMaskIntoConstraints = false
  view.addSubview(bannerView)
  if #available(iOS 11.0, *) {
    // In iOS 11, we need to constrain the view to the safe area.
    positionBannerViewFullWidthAtBottomOfSafeArea(bannerView)
  }
  else {
    // In lower iOS versions, safe area is not available so we use
    // bottom layout guide and view edges.
    positionBannerViewFullWidthAtBottomOfView(bannerView)
  }
}

// MARK: - view positioning
@available (iOS 11, *)
func positionBannerViewFullWidthAtBottomOfSafeArea(_ bannerView: UIView) {
  // Position the banner. Stick it to the bottom of the Safe Area.
  // Make it constrained to the edges of the safe area.
  let guide = view.safeAreaLayoutGuide
  NSLayoutConstraint.activate([
    guide.leftAnchor.constraint(equalTo: bannerView.leftAnchor),
    guide.rightAnchor.constraint(equalTo: bannerView.rightAnchor),
    guide.bottomAnchor.constraint(equalTo: bannerView.bottomAnchor)
  ])
}

func positionBannerViewFullWidthAtBottomOfView(_ bannerView: UIView) {
  view.addConstraint(NSLayoutConstraint(item: bannerView,
                                        attribute: .leading,
                                        relatedBy: .equal,
                                        toItem: view,
                                        attribute: .leading,
                                        multiplier: 1,
                                        constant: 0))
  view.addConstraint(NSLayoutConstraint(item: bannerView,
                                        attribute: .trailing,
                                        relatedBy: .equal,
                                        toItem: view,
                                        attribute: .trailing,
                                        multiplier: 1,
                                        constant: 0))
  view.addConstraint(NSLayoutConstraint(item: bannerView,
                                        attribute: .bottom,
                                        relatedBy: .equal,
                                        toItem: bottomLayoutGuide,
                                        attribute: .top,
                                        multiplier: 1,
                                        constant: 0))
}

উদ্দেশ্য গ

- (void)addBannerViewToView:(UIView *)bannerView {
  bannerView.translatesAutoresizingMaskIntoConstraints = NO;
  [self.view addSubview:bannerView];
  if (@available(ios 11.0, *)) {
    // In iOS 11, we need to constrain the view to the safe area.
    [self positionBannerViewFullWidthAtBottomOfSafeArea:bannerView];
  } else {
    // In lower iOS versions, safe area is not available so we use
    // bottom layout guide and view edges.
    [self positionBannerViewFullWidthAtBottomOfView:bannerView];
  }
}

#pragma mark - view positioning

- (void)positionBannerViewFullWidthAtBottomOfSafeArea:(UIView *_Nonnull)bannerView NS_AVAILABLE_IOS(11.0) {
  // Position the banner. Stick it to the bottom of the Safe Area.
  // Make it constrained to the edges of the safe area.
  UILayoutGuide *guide = self.view.safeAreaLayoutGuide;

  [NSLayoutConstraint activateConstraints:@[
    [guide.leftAnchor constraintEqualToAnchor:bannerView.leftAnchor],
    [guide.rightAnchor constraintEqualToAnchor:bannerView.rightAnchor],
    [guide.bottomAnchor constraintEqualToAnchor:bannerView.bottomAnchor]
  ]];
}

- (void)positionBannerViewFullWidthAtBottomOfView:(UIView *_Nonnull)bannerView {
  [self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView
                                                        attribute:NSLayoutAttributeLeading
                                                        relatedBy:NSLayoutRelationEqual
                                                           toItem:self.view
                                                        attribute:NSLayoutAttributeLeading
                                                       multiplier:1
                                                         constant:0]];
  [self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView
                                                        attribute:NSLayoutAttributeTrailing
                                                        relatedBy:NSLayoutRelationEqual
                                                           toItem:self.view
                                                        attribute:NSLayoutAttributeTrailing
                                                       multiplier:1
                                                         constant:0]];
  [self.view addConstraint:[NSLayoutConstraint constraintWithItem:bannerView
                                                        attribute:NSLayoutAttributeBottom
                                                        relatedBy:NSLayoutRelationEqual
                                                           toItem:self.bottomLayoutGuide
                                                        attribute:NSLayoutAttributeTop
                                                       multiplier:1
                                                         constant:0]];
}

নেটিভ বিজ্ঞাপন

যদি আপনার অ্যাপ নেটিভ বিজ্ঞাপনগুলিকে স্ক্রিনের উপরে বা নীচে পিন করে, তাহলে একই নীতিগুলি নেটিভ বিজ্ঞাপনগুলির জন্য প্রযোজ্য হবে যেমনটি তারা ব্যানার বিজ্ঞাপনগুলির জন্য করে। মূল পার্থক্য হল একটি GADBannerView এ সীমাবদ্ধতা যোগ করার পরিবর্তে, নিরাপদ এলাকা লেআউট নির্দেশিকাকে সম্মান করার জন্য আপনাকে আপনার GADUnifiedNativeAdView (বা বিজ্ঞাপনের জন্য থাকা ভিউ) তে সীমাবদ্ধতা যোগ করতে হবে। নেটিভ ভিউয়ের জন্য আমরা আরও স্পষ্ট আকারের সীমাবদ্ধতা প্রদান করার পরামর্শ দিই।

ইন্টারস্টিশিয়াল এবং পুরস্কৃত বিজ্ঞাপন

সংস্করণ 7.26.0 অনুযায়ী, Google মোবাইল বিজ্ঞাপন SDK iPhone X-এর জন্য ইন্টারস্টিশিয়াল এবং পুরস্কৃত বিজ্ঞাপন ফর্ম্যাটগুলিকে সম্পূর্ণরূপে সমর্থন করে৷