ব্যানার বিজ্ঞাপন

Banner views are rectangular image or text ads that occupy a spot on screen. They stay on screen while users are interacting with the app, and can refresh automatically after a certain period of time. If you're new to mobile advertising, they're a great place to start.

This guide shows you how to integrate banner views into a Unity app. In addition to code snippets and instructions, it also includes information about sizing banners properly and links to additional resources.

পূর্বশর্ত

সর্বদা পরীক্ষামূলক বিজ্ঞাপন দিয়ে পরীক্ষা করুন

The following sample code contains an ad unit ID which you can use to request test ads. It's been specially configured to return test ads rather than production ads for every request, making it safe to use.

However, after you've registered an app in the Ad Manager web interface and created your own ad unit IDs for use in your app, explicitly configure your device as a test device during development.

/21775744923/example/fixed-size-banner

মোবাইল বিজ্ঞাপন SDK চালু করুন

বিজ্ঞাপন লোড করার আগে, আপনার অ্যাপটিকে MobileAds.Initialize() কল করে Google Mobile Ads Unity Plugin চালু করতে বলুন। এটি শুধুমাত্র একবার করতে হবে, আদর্শভাবে অ্যাপ লঞ্চের সময়।

using GoogleMobileAds;
using GoogleMobileAds.Api;

public class GoogleMobileAdsDemoScript : MonoBehaviour
{
    public void Start()
    {
        // Initialize Google Mobile Ads Unity Plugin.
        MobileAds.Initialize((InitializationStatus initStatus) =>
        {
            // This callback is called once the MobileAds SDK is initialized.
        });
    }
}

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

ব্যানারভিউ উদাহরণ

The following sample code details how to use the banner view. In the example, create an instance of a banner view, use an AdManagerAdRequest to load an ad into the banner view, and then extend its capabilities by handling lifecycle events.

একটি ব্যানার ভিউ তৈরি করুন

ব্যানার ভিউ ব্যবহারের প্রথম ধাপ হল ব্যানার ভিউয়ের একটি উদাহরণ তৈরি করা।

// Create a 320x50 banner at top of the screen.
adManagerBannerView = new AdManagerBannerView("AD_UNIT_ID", AdSize.Banner, AdPosition.Top);

AD_UNIT_ID এর পরিবর্তে আপনার বিজ্ঞাপন ইউনিট আইডি দিন।

একটি AdManagerBannerView এর কনস্ট্রাক্টরের নিম্নলিখিত প্যারামিটার রয়েছে:

  • adUnitId : লোড করা ব্যানার বিজ্ঞাপনের বিজ্ঞাপন ইউনিট আইডি।
  • AdSize : আপনি যে ব্যানারের আকার ব্যবহার করতে চান।
  • AdPosition : ব্যানার ভিউ যেখানে স্থাপন করা উচিত সেই অবস্থান।

(ঐচ্ছিক) একটি কাস্টম অবস্থান সহ একটি ব্যানার ভিউ তৈরি করুন

AdPosition মানগুলির তুলনায় স্ক্রিনে ব্যানার ভিউ কোথায় স্থাপন করা হবে তার উপর আরও বেশি নিয়ন্ত্রণের জন্য, প্যারামিটার হিসাবে x- এবং y-স্থানাঙ্কযুক্ত কনস্ট্রাক্টর ব্যবহার করুন:

// Create a 320x50 banner views at coordinate (0,50) on screen.
adManagerBannerView = new AdManagerBannerView("AD_UNIT_ID", AdSize.Banner, 0, 50);

ব্যানার ভিউয়ের উপরের-বাম কোণটি কনস্ট্রাক্টরের কাছে প্রেরিত x এবং y মানের উপর অবস্থিত, যেখানে অরিজিনটি স্ক্রিনের উপরের-বাম দিকে অবস্থিত।

(ঐচ্ছিক) একটি কাস্টম আকার দিয়ে একটি ব্যানার ভিউ তৈরি করুন

AdSize ধ্রুবক ব্যবহার করার পাশাপাশি, আপনি আপনার বিজ্ঞাপনের জন্য একটি কাস্টম আকারও নির্দিষ্ট করতে পারেন:

// Create a 250x250 banner at the bottom of the screen.
AdSize adSize = new AdSize(250, 250);
adManagerBannerView = new AdManagerBannerView("AD_UNIT_ID", adSize, AdPosition.Bottom);

(ঐচ্ছিক) একাধিক বিজ্ঞাপনের আকার

Ad Manager lets you specify multiple ad sizes which could be eligible to serve in an AdManagerBannerView . Before implementing this feature in the SDK, create a line item targeting the same ad units associated with different size creatives.

আপনার অ্যাপে, একাধিক AdSize প্যারামিটার ValidAdSizes এ পাস করুন:

// Create a 250x250 banner at the bottom of the screen.
adManagerBannerView = new AdManagerBannerView("AD_UNIT_ID", AdSize.Banner, AdPosition.Top);

// Add multiple ad sizes.
adManagerBannerView.ValidAdSizes = new List<AdSize>
{
    AdSize.Banner,
    new AdSize(120, 20),
    new AdSize(250, 250),
};

If AdManagerAdView changes size at refresh time, your layout should be able to automatically adapt to the new size. AdManagerAdView defaults to the size passed in the first parameter until the next ad returns.

একটি ব্যানার বিজ্ঞাপন লোড করুন

AdManagerBannerView চালু হওয়ার পর, AdManagerBannerView ক্লাসে LoadAd() পদ্ধতি ব্যবহার করে একটি বিজ্ঞাপন লোড করতে এগিয়ে যান। এটির জন্য একটি এমন প্যারামিটার যা রানটাইম তথ্য ধারণ করে, যেমন টার্গেটিং তথ্য, বর্জন লেবেল এবং প্রকাশকের প্রদত্ত আইডি।

একটি বিজ্ঞাপন লোড করতে, একটি AdManagerAdRequest তৈরি করুন এবং এটি LoadAd() পদ্ধতিতে পাস করুন।

// Send a request to load an ad into the banner view.
adManagerBannerView.LoadAd(new AdManagerAdRequest());

ব্যানার ভিউ ইভেন্টগুলি শুনুন

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

adManagerBannerView.OnBannerAdLoaded += () =>
{
    // Raised when an ad is loaded into the banner view.
};
adManagerBannerView.OnBannerAdLoadFailed += (LoadAdError error) =>
{
    // Raised when an ad fails to load into the banner view.
};
adManagerBannerView.OnAdPaid += (AdValue adValue) =>
{
    // Raised when the ad is estimated to have earned money.
};
adManagerBannerView.OnAdImpressionRecorded += () =>
{
    // Raised when an impression is recorded for an ad.
};
adManagerBannerView.OnAdClicked += () =>
{
    // Raised when a click is recorded for an ad.
};
adManagerBannerView.OnAdFullScreenContentOpened += () =>
{
    // Raised when an ad opened full screen content.
};
adManagerBannerView.OnAdFullScreenContentClosed += () =>
{
    // Raised when the ad closed full screen content.
};

ব্যানার ভিউ নষ্ট করে দিন

ব্যানারটি ধ্বংস করতে, রিসোর্স প্রকাশ করতে Destroy() পদ্ধতিটি কল করুন:

if (adManagerBannerView != null)
{
    // Always destroy the banner view when no longer needed.
    adManagerBannerView.Destroy();
    adManagerBannerView = null;
}

যেসব ব্যানার লোড হতে ব্যর্থ হয়, আমরা আপনাকে নতুন ব্যানার তৈরি করার পরিবর্তে ব্যানারটি রিফ্রেশ করার পরামর্শ দিচ্ছি। বিস্তারিত জানার জন্য, "বিজ্ঞাপন রিফ্রেশ করুন" দেখুন।

একটি বিজ্ঞাপন রিফ্রেশ করুন

If you configured your ad unit to refresh, you don't need to request another ad when the ad fails to load. Google Mobile Ads Unity Plugin respects any refresh rate you specified in the Ad Manager UI. If you haven't enabled refresh, issue a new request. For more details on ad unit refresh, such as setting a refresh rate, see Refresh rate for ads in mobile apps .

নিম্নলিখিত টেবিলে স্ট্যান্ডার্ড ব্যানারের আকারগুলি তালিকাভুক্ত করা হয়েছে:

আকার dp (WxH) তে বিবরণ উপস্থিতি বিজ্ঞাপন আকার ধ্রুবক
৩২০x৫০ স্ট্যান্ডার্ড ব্যানার ফোন এবং ট্যাবলেট BANNER
৩২০x১০০ বড় ব্যানার ফোন এবং ট্যাবলেট LARGE_BANNER
৩০০x২৫০ IAB মাঝারি আয়তক্ষেত্র ফোন এবং ট্যাবলেট MEDIUM_RECTANGLE
৪৬৮x৬০ IAB পূর্ণ-আকারের ব্যানার ট্যাবলেট FULL_BANNER
৭২৮x৯০ IAB লিডারবোর্ড ট্যাবলেট LEADERBOARD
প্রদত্ত প্রস্থ x অভিযোজিত উচ্চতা অ্যাডাপ্টিভ ব্যানার ফোন এবং ট্যাবলেট নিষিদ্ধ
স্ক্রিনের প্রস্থ x ৩২|৫০|৯০ স্মার্ট ব্যানার ফোন এবং ট্যাবলেট SMART_BANNER
স্মার্ট ব্যানার প্রতিস্থাপনের উদ্দেশ্যে তৈরি অ্যাডাপ্টিভ ব্যানার সম্পর্কে আরও জানুন।

অ্যাপ ইভেন্ট

অ্যাপ ইভেন্টগুলি আপনাকে এমন বিজ্ঞাপন তৈরি করতে দেয় যা তাদের অ্যাপ কোডে বার্তা পাঠাতে পারে। এরপর অ্যাপটি এই বার্তাগুলির উপর ভিত্তি করে পদক্ষেপ নিতে পারে।

আপনি AppEvent ব্যবহার করে বিজ্ঞাপন ম্যানেজারের নির্দিষ্ট অ্যাপ ইভেন্টগুলি শুনতে পারেন। এই ইভেন্টগুলি বিজ্ঞাপনের জীবনচক্রের যেকোনো সময় ঘটতে পারে, এমনকি লোড কল হওয়ার আগেই।

OnAppEventReceived is raised when an app event occurs in an ad. Here is an example of how to handle this event in your code:

adManagerBannerView.OnAppEventReceived += (AppEvent args) =>
{
    Debug.Log($"Received app event from the ad: {args.Name}, {args.Data}.");
};

রঙের নামের অ্যাপ ইভেন্টের উপর নির্ভর করে আপনার অ্যাপের ব্যাকগ্রাউন্ডের রঙ কীভাবে পরিবর্তন করবেন তা দেখানোর একটি উদাহরণ এখানে দেওয়া হল:

adManagerBannerView.OnAppEventReceived += (AppEvent args) =>
{
    if (args.Name == "color")
    {
        Color color;
        if (ColorUtility.TryParseHtmlString(args.Data, out color))
        {
            renderer.material.color = color;
        }
    }
};

এবং, এখানে সংশ্লিষ্ট সৃজনশীলটি রয়েছে যা রঙিন অ্যাপ ইভেন্ট পাঠায়:

<html>
<head>
  <script src="//www.gstatic.com/afma/api/v1/google_mobile_app_ads.js"></script>
  <script>
    document.addEventListener("DOMContentLoaded", function() {
      // Send a color=green event when ad loads.
      admob.events.dispatchAppEvent("color", "green");

      document.getElementById("ad").addEventListener("click", function() {
        // Send a color=blue event when ad is clicked.
        admob.events.dispatchAppEvent("color", "blue");
      });
    });
  </script>
  <style>
    #ad {
      width: 320px;
      height: 50px;
      top: 0;
      left: 0;
      font-size: 24pt;
      font-weight: bold;
      position: absolute;
      background: black;
      color: white;
      text-align: center;
    }
  </style>
</head>
<body>
  <div id="ad">Carpe diem!</div>
</body>
</html>

অতিরিক্ত সম্পদ

  • HelloWorld উদাহরণ : সকল বিজ্ঞাপন ফর্ম্যাটের একটি ন্যূনতম বাস্তবায়ন।