ইন্টারস্টিশিয়াল বিজ্ঞাপন

Interstitial ads are full-screen ads that cover the interface of their host app. They're typically displayed at natural transition points in the flow of an app, such as between activities or during the pause between levels in a game. When an app shows an interstitial ad, the user has the choice to either tap on the ad and continue to its destination or close it and return to the app.

This guide explains how to integrate interstitial ads into a Flutter app.

সর্বদা টেস্ট অ্যাড দিয়ে পরীক্ষা করুন

আপনার অ্যাপ তৈরি ও পরীক্ষা করার সময়, লাইভ বা প্রোডাকশন অ্যাডের পরিবর্তে টেস্ট অ্যাড ব্যবহার করুন। এটি করতে ব্যর্থ হলে আপনার অ্যাকাউন্ট সাসপেন্ড হতে পারে।

The easiest way to load test ads is to use our dedicated test ad unit ID for interstitials:

অ্যান্ড্রয়েড

ca-app-pub-3940256099942544/1033173712

আইওএস

ca-app-pub-3940256099942544/4411468910

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

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

The following example loads an interstitial ad:

InterstitialAd.load(
  adUnitId: "_adUnitId",
  request: const AdRequest(),
  adLoadCallback: InterstitialAdLoadCallback(
    onAdLoaded: (InterstitialAd ad) {
      // Called when an ad is successfully received.
      debugPrint('Ad was loaded.');
      // Keep a reference to the ad so you can show it later.
      _interstitialAd = ad;
    },
    onAdFailedToLoad: (LoadAdError error) {
      // Called when an ad request failed.
      debugPrint('Ad failed to load with error: $error');
    },
  ),
);

_adUnitId জায়গায় আপনার নিজের বিজ্ঞাপন ইউনিটের আইডি বসান।

Interstitial ad events

Through the use of FullScreenContentCallback , you can listen for lifecycle events, such as when the ad is shown or dismissed. Set InterstitialAd.fullScreenContentCallback before showing the ad to receive notifications for these events. This example implements each method:

ad.fullScreenContentCallback = FullScreenContentCallback(
  onAdShowedFullScreenContent: (ad) {
    // Called when the ad showed the full screen content.
    debugPrint('Ad showed full screen content.');
  },
  onAdFailedToShowFullScreenContent: (ad, err) {
    // Called when the ad failed to show full screen content.
    debugPrint('Ad failed to show full screen content with error: $err');
    // Dispose the ad here to free resources.
    ad.dispose();
  },
  onAdDismissedFullScreenContent: (ad) {
    // Called when the ad dismissed full screen content.
    debugPrint('Ad was dismissed.');
    // Dispose the ad here to free resources.
    ad.dispose();
  },
  onAdImpression: (ad) {
    // Called when an impression occurs on the ad.
    debugPrint('Ad recorded an impression.');
  },
  onAdClicked: (ad) {
    // Called when a click is recorded for an ad.
    debugPrint('Ad was clicked.');
  },
);

Display an interstitial ad

An InterstitialAd is displayed as an Overlay on top of all app content and is statically placed; thus, it can't be added to the Flutter widget tree. You can choose when to show the ad by calling show() .

_interstitialAd?.show();

Once show() is called, an Ad displayed this way can't be dismissed programmatically and requires user input. An InterstitialAd can only be shown once. Subsequent calls to show will trigger onAdFailedToShowFullScreenContent .

An ad must be disposed when access to it is no longer needed. The best practice for when to call dispose() is in the FullScreenContentCallback.onAdDismissedFullScreenContent and FullScreenContentCallback.onAdFailedToShowFullScreenContent callbacks.

That's it! Your app is now ready to display interstitial ads.

Next steps

গিটহাবে সম্পূর্ণ উদাহরণ

ইন্টারস্টিশিয়াল