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

পূর্বশর্ত
- শুরু করুন নির্দেশিকাটি সম্পূর্ণ করুন।
- ইউনিটি প্লাগইন ৭.১.০ বা তার বেশি।
সর্বদা পরীক্ষামূলক বিজ্ঞাপন দিয়ে পরীক্ষা করুন
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/app-open
বাস্তবায়ন
অ্যাপ ওপেন বিজ্ঞাপন সংহত করার প্রধান ধাপগুলি হল:
- একটি ইউটিলিটি ক্লাস তৈরি করুন
- অ্যাপ খোলার বিজ্ঞাপন লোড করুন
- অ্যাপ খোলা বিজ্ঞাপন ইভেন্টগুলি শুনুন
- বিজ্ঞাপনের মেয়াদ শেষ হওয়ার কথা বিবেচনা করুন
- অ্যাপের অবস্থা সংক্রান্ত ইভেন্টগুলি শুনুন
- অ্যাপ খোলার বিজ্ঞাপন দেখান
- অ্যাপটি পরিষ্কার করে বিজ্ঞাপনটি খুলুন
- পরবর্তী অ্যাপ খোলার বিজ্ঞাপনটি প্রিলোড করুন
একটি ইউটিলিটি ক্লাস তৈরি করুন
বিজ্ঞাপনটি লোড করার জন্য AppOpenAdController নামে একটি নতুন ক্লাস তৈরি করুন। এই ক্লাসটি প্রতিটি প্ল্যাটফর্মের জন্য লোড করা বিজ্ঞাপন এবং বিজ্ঞাপন ইউনিট আইডি ট্র্যাক করার জন্য একটি ইনস্ট্যান্স ভেরিয়েবল নিয়ন্ত্রণ করে।
using System;
using UnityEngine;
using GoogleMobileAds.Api;
using GoogleMobileAds.Common;
/// <summary>
/// Demonstrates how to use the Google Mobile Ads app open ad format.
/// </summary>
[AddComponentMenu("GoogleMobileAds/Samples/AppOpenAdController")]
public class AppOpenAdController : MonoBehaviour
{
// This ad unit is configured to always serve test ads.
private string _adUnitId = "/21775744923/example/app-open";
public bool IsAdAvailable
{
get
{
return _appOpenAd != null;
}
}
public void Start()
{
// Initialize Google Mobile Ads Unity Plugin.
MobileAds.Initialize((InitializationStatus initStatus) =>
{
// This callback is called once the MobileAds SDK is initialized.
});
}
/// <summary>
/// Loads the app open ad.
/// </summary>
public void LoadAppOpenAd()
{
}
/// <summary>
/// Shows the app open ad.
/// </summary>
public void ShowAppOpenAd()
{
}
}
অ্যাপ খোলার বিজ্ঞাপন লোড করুন
Loading an app open ad is accomplished using the static Load() method on the AppOpenAd class. The load method requires an ad unit ID, an AdManagerAdRequest object, and a completion handler which gets called when ad loading succeeds or fails. The loaded AppOpenAd object is provided as a parameter in the completion handler. The example below shows how to load an AppOpenAd .
// This ad unit is configured to always serve test ads.
private string _adUnitId = "/21775744923/example/app-open";
private AppOpenAd appOpenAd;
/// <summary>
/// Loads the app open ad.
/// </summary>
public void LoadAppOpenAd()
{
// Clean up the old ad before loading a new one.
if (appOpenAd != null)
{
appOpenAd.Destroy();
appOpenAd = null;
}
Debug.Log("Loading the app open ad.");
// Create our request used to load the ad.
var adRequest = new AdManagerAdRequest();
// send the request to load the ad.
AppOpenAd.Load(_adUnitId, adRequest,
(AppOpenAd ad, LoadAdError error) =>
{
// if error is not null, the load request failed.
if (error != null || ad == null)
{
Debug.LogError("app open ad failed to load an ad " +
"with error : " + error);
return;
}
Debug.Log("App open ad loaded with response : "
+ ad.GetResponseInfo());
appOpenAd = ad;
RegisterEventHandlers(ad);
});
}
অ্যাপ খোলা বিজ্ঞাপন ইভেন্টগুলি শুনুন
To further customize the behavior of your ad, you can hook into a number of events in the ad's lifecycle: opening, closing, and so on. Listen for these events by registering a delegate as shown below.
private void RegisterEventHandlers(AppOpenAd ad)
{
// Raised when the ad is estimated to have earned money.
ad.OnAdPaid += (AdValue adValue) =>
{
Debug.Log(String.Format("App open ad paid {0} {1}.",
adValue.Value,
adValue.CurrencyCode));
};
// Raised when an impression is recorded for an ad.
ad.OnAdImpressionRecorded += () =>
{
Debug.Log("App open ad recorded an impression.");
};
// Raised when a click is recorded for an ad.
ad.OnAdClicked += () =>
{
Debug.Log("App open ad was clicked.");
};
// Raised when an ad opened full screen content.
ad.OnAdFullScreenContentOpened += () =>
{
Debug.Log("App open ad full screen content opened.");
};
// Raised when the ad closed full screen content.
ad.OnAdFullScreenContentClosed += () =>
{
Debug.Log("App open ad full screen content closed.");
};
// Raised when the ad failed to open full screen content.
ad.OnAdFullScreenContentFailed += (AdError error) =>
{
Debug.LogError("App open ad failed to open full screen content " +
"with error : " + error);
};
}
বিজ্ঞাপনের মেয়াদ শেষ হওয়ার কথা বিবেচনা করুন
মেয়াদোত্তীর্ণ বিজ্ঞাপন যাতে না দেখায়, তার জন্য AppOpenAdController এ একটি পদ্ধতি যোগ করুন যা আপনার বিজ্ঞাপন লোড হওয়ার পর কতক্ষণ হয়েছে তা পরীক্ষা করে। তারপর, বিজ্ঞাপনটি এখনও বৈধ কিনা তা পরীক্ষা করার জন্য সেই পদ্ধতিটি ব্যবহার করুন।
অ্যাপ খোলা বিজ্ঞাপনটির ৪ ঘন্টার টাইমআউট আছে। লোড টাইম _expireTime ভেরিয়েবলে ক্যাশে করুন।
// send the request to load the ad.
AppOpenAd.Load(_adUnitId, adRequest,
(AppOpenAd ad, LoadAdError error) =>
{
// If the operation failed, an error is returned.
if (error != null || ad == null)
{
Debug.LogError("App open ad failed to load an ad with error : " +
error);
return;
}
// If the operation completed successfully, no error is returned.
Debug.Log("App open ad loaded with response : " + ad.GetResponseInfo());
// App open ads can be preloaded for up to 4 hours.
_expireTime = DateTime.Now + TimeSpan.FromHours(4);
_appOpenAd = ad;
});
লোড করা বিজ্ঞাপনটি এখনও বৈধ কিনা তা নিশ্চিত করতে _expireTime চেক করতে IsAdAvailable প্রপার্টি আপডেট করুন।
public bool IsAdAvailable
{
get
{
return _appOpenAd != null
&& _appOpenAd.IsLoaded()
&& DateTime.Now < _expireTime;
}
}
অ্যাপের অবস্থা সংক্রান্ত ইভেন্টগুলি শুনুন
অ্যাপ্লিকেশনের ফোরগ্রাউন্ড এবং ব্যাকগ্রাউন্ড ইভেন্টগুলি শুনতে AppStateEventNotifier ব্যবহার করুন। যখনই অ্যাপ্লিকেশনটি ফোরগ্রাউন্ড বা ব্যাকগ্রাউন্ডে প্রদর্শিত হবে তখনই এই ক্লাসটি AppStateChanged ইভেন্টটি উত্থাপন করবে।
private void Awake()
{
// Use the AppStateEventNotifier to listen to application open/close events.
// This is used to launch the loaded ad when we open the app.
AppStateEventNotifier.AppStateChanged += OnAppStateChanged;
}
private void OnDestroy()
{
// Always unlisten to events when complete.
AppStateEventNotifier.AppStateChanged -= OnAppStateChanged;
}
যখন আমরা AppState.Foreground অবস্থা পরিচালনা করি এবং IsAdAvailable true হয়, তখন আমরা বিজ্ঞাপনটি দেখানোর জন্য ShowAppOpenAd() কল করি।
private void OnAppStateChanged(AppState state)
{
Debug.Log("App State changed to : "+ state);
// if the app is Foregrounded and the ad is available, show it.
if (state == AppState.Foreground)
{
if (IsAdAvailable)
{
ShowAppOpenAd();
}
}
}
অ্যাপ খোলার বিজ্ঞাপন দেখান
লোড করা অ্যাপ খোলা বিজ্ঞাপন দেখানোর জন্য, AppOpenAd ইনস্ট্যান্সে Show() পদ্ধতিতে কল করুন। প্রতি লোডে বিজ্ঞাপন শুধুমাত্র একবার দেখানো যাবে। বিজ্ঞাপনটি দেখানোর জন্য প্রস্তুত কিনা তা যাচাই করতে CanShowAd() পদ্ধতি ব্যবহার করুন।
/// <summary>
/// Shows the app open ad.
/// </summary>
public void ShowAppOpenAd()
{
if (appOpenAd != null && appOpenAd.CanShowAd())
{
Debug.Log("Showing app open ad.");
appOpenAd.Show();
}
else
{
Debug.LogError("App open ad is not ready yet.");
}
}
অ্যাপটি পরিষ্কার করে বিজ্ঞাপনটি খুলুন
যখন আপনি একটি AppOpenAd তৈরি শেষ করবেন, তখন আপনার রেফারেন্সটি বাদ দেওয়ার আগে Destroy() পদ্ধতিটি কল করতে ভুলবেন না:
appOpenAd.Destroy();
এটি প্লাগইনটিকে অবহিত করে যে বস্তুটি আর ব্যবহৃত হচ্ছে না এবং এটি যে মেমরি দখল করে আছে তা পুনরুদ্ধার করা যেতে পারে। এই পদ্ধতিটি কল করতে ব্যর্থ হলে মেমরি লিক হয়।
পরবর্তী অ্যাপ খোলার বিজ্ঞাপনটি প্রিলোড করুন
AppOpenAd হল একটি একবার ব্যবহারযোগ্য অবজেক্ট। এর অর্থ হল একবার একটি অ্যাপ খোলা বিজ্ঞাপন দেখানো হলে, অবজেক্টটি আর ব্যবহার করা যাবে না। আরেকটি অ্যাপ খোলা বিজ্ঞাপনের অনুরোধ করতে, আপনাকে একটি নতুন AppOpenAd অবজেক্ট তৈরি করতে হবে।
পরবর্তী ইম্প্রেশন সুযোগের জন্য একটি অ্যাপ ওপেন বিজ্ঞাপন প্রস্তুত করতে, OnAdFullScreenContentClosed বা OnAdFullScreenContentFailed বিজ্ঞাপন ইভেন্টটি উত্থাপিত হওয়ার পরে অ্যাপ ওপেন বিজ্ঞাপনটি প্রিলোড করুন।
private void RegisterReloadHandler(AppOpenAd ad)
{
...
// Raised when the ad closed full screen content.
ad.OnAdFullScreenContentClosed += ()
{
Debug.Log("App open ad full screen content closed.");
// Reload the ad so that we can show another as soon as possible.
LoadAppOpenAd();
};
// Raised when the ad failed to open full screen content.
ad.OnAdFullScreenContentFailed += (AdError error) =>
{
Debug.LogError("App open ad failed to open full screen content " +
"with error : " + error);
// Reload the ad so that we can show another as soon as possible.
LoadAppOpenAd();
};
}
কোল্ড স্টার্ট এবং লোডিং স্ক্রিন
এখন পর্যন্ত ডকুমেন্টেশন ধরে নিয়েছে যে ব্যবহারকারীরা যখন আপনার অ্যাপটি মেমোরিতে সাসপেন্ড করা থাকে তখনই কেবল অ্যাপ ওপেন বিজ্ঞাপন দেখান। "কোল্ড স্টার্ট" তখন ঘটে যখন আপনার অ্যাপটি চালু হয় কিন্তু আগে মেমোরিতে সাসপেন্ড করা হয়নি।
কোল্ড স্টার্টের একটি উদাহরণ হল যখন একজন ব্যবহারকারী প্রথমবার আপনার অ্যাপটি খোলেন। কোল্ড স্টার্টের মাধ্যমে, আপনার কাছে পূর্বে লোড করা কোনও অ্যাপ খোলা বিজ্ঞাপন থাকবে না যা তাৎক্ষণিকভাবে দেখানোর জন্য প্রস্তুত। আপনি যখন একটি বিজ্ঞাপনের অনুরোধ করেন এবং একটি বিজ্ঞাপন ফেরত পান তার মধ্যে বিলম্ব এমন পরিস্থিতি তৈরি করতে পারে যেখানে ব্যবহারকারীরা আপনার অ্যাপটি সংক্ষিপ্তভাবে ব্যবহার করতে সক্ষম হন এবং তারপরে কোনও অপ্রাসঙ্গিক বিজ্ঞাপন দেখে অবাক হন। এটি এড়ানো উচিত কারণ এটি একটি খারাপ ব্যবহারকারীর অভিজ্ঞতা।
The preferred way to use app open ads on cold starts is to use a loading screen to load your game or app assets, and to only show the ad from the loading screen. If your app has completed loading and has sent the user to the main content of your app, do not show the ad.
সেরা অনুশীলন
App open ads help you monetize your app's loading screen when the app first launches and during app switches, but it's important to keep the following best practices in mind so that your users enjoy using your app.
- আপনার ব্যবহারকারীরা আপনার অ্যাপটি কয়েকবার ব্যবহার করার পরে আপনার প্রথম অ্যাপ খোলা বিজ্ঞাপনটি দেখান।
- যখন আপনার ব্যবহারকারীরা আপনার অ্যাপ লোড হওয়ার জন্য অপেক্ষা করবেন, তখন অ্যাপ খোলার বিজ্ঞাপনগুলি দেখান।
- If you have a loading screen under the app open ad and your loading screen completes loading before the ad is dismissed, dismiss your loading screen in the
OnAdDidDismissFullScreenContentevent handler. - On the iOS platform,
AppStateEventNotifierinstantiates anAppStateEventClient GameObject. ThisGameObjectis required for events to fire so don't destroy it. Events stop firing if theGameObjectis destroyed.
অতিরিক্ত সম্পদ
- HelloWorld উদাহরণ : সকল বিজ্ঞাপন ফর্ম্যাটের একটি ন্যূনতম বাস্তবায়ন।