পূর্বশর্ত
কাস্টম ইভেন্ট সেটআপ সম্পূর্ণ করুন।
একটি ইন্টারস্টিশিয়াল বিজ্ঞাপনের অনুরোধ করুন
 যখন ওয়াটারফল মেডিটেশন চেইনে কাস্টম ইভেন্ট লাইন আইটেমটি পৌঁছানো হয়, তখন একটি কাস্টম ইভেন্ট তৈরি করার সময় আপনার দেওয়া ক্লাসের নামের উপর loadInterstitial:adConfiguration:completionHandler: পদ্ধতিটি ডাকা হয়। এই ক্ষেত্রে, সেই পদ্ধতিটি SampleCustomEvent এ থাকে, যা পরে SampleCustomEventInterstitial এ loadInterstitial:adConfiguration:completionHandler: পদ্ধতিটিকে ডাকে।
 একটি ইন্টারস্টিশিয়াল বিজ্ঞাপনের অনুরোধ করতে, এমন একটি ক্লাস তৈরি বা পরিবর্তন করুন যা GADMediationAdapter এবং loadInterstitial:adConfiguration:completionHandler: প্রয়োগ করে। যদি GADMediationAdapter প্রসারিত করে এমন একটি ক্লাস ইতিমধ্যেই বিদ্যমান থাকে, তাহলে সেখানে loadInterstitial:adConfiguration:completionHandler: প্রয়োগ করুন। অতিরিক্তভাবে, GADMediationInterstitialAd বাস্তবায়নের জন্য একটি নতুন ক্লাস তৈরি করুন।
 আমাদের কাস্টম ইভেন্ট উদাহরণে, SampleCustomEvent GADMediationAdapter ইন্টারফেস প্রয়োগ করে এবং তারপর SampleCustomEventInterstitial এ ডেলিগেট করে। 
সুইফট
import GoogleMobileAds class SampleCustomEvent: NSObject, MediationAdapter { fileprivate var interstitialAd: SampleCustomEventInterstitial? ... func loadInterstitial( for adConfiguration: MediationInterstitialAdConfiguration, completionHandler: @escaping GADMediationInterstitialLoadCompletionHandler ) { self.interstitialAd = SampleCustomEventInterstitial() self.interstitialAd?.loadInterstitial( for: adConfiguration, completionHandler: completionHandler) } }
অবজেক্টিভ-সি
#import "SampleCustomEvent.h" @implementation SampleCustomEvent SampleCustomEventInterstitial *sampleInterstitial; - (void)loadInterstitialForAdConfiguration: (GADMediationInterstitialAdConfiguration *)adConfiguration completionHandler: (GADMediationInterstitialLoadCompletionHandler) completionHandler { sampleInterstitial = [[SampleCustomEventInterstitial alloc] init]; [sampleInterstitial loadInterstitialForAdConfiguration:adConfiguration completionHandler:completionHandler]; }
 SampleCustomEventInterstitial নিম্নলিখিত কাজগুলির জন্য দায়ী:
লোডিং সম্পূর্ণ হলে ইন্টারস্টিশিয়াল বিজ্ঞাপন লোড করা এবং
GADMediationInterstitialAdLoadCompletionHandlerপদ্ধতি ব্যবহার করা।GADMediationInterstitialAdপ্রোটোকল বাস্তবায়ন করা।Google মোবাইল বিজ্ঞাপন SDK-তে বিজ্ঞাপন ইভেন্ট কলব্যাক গ্রহণ এবং রিপোর্ট করা।
 ঐচ্ছিক প্যারামিটারটি সংজ্ঞায়িত করা হয়েছে  বিজ্ঞাপন কনফিগারেশনে UI অন্তর্ভুক্ত থাকে। adConfiguration.credentials.settings[@"parameter"] এর মাধ্যমে প্যারামিটারটি অ্যাক্সেস করা যেতে পারে। এই প্যারামিটারটি সাধারণত একটি বিজ্ঞাপন ইউনিট শনাক্তকারী যা একটি বিজ্ঞাপন নেটওয়ার্ক SDK-এর জন্য একটি বিজ্ঞাপন বস্তু ইনস্ট্যান্টিয়েট করার সময় প্রয়োজন হয়। 
সুইফট
import GoogleMobileAds class SampleCustomEventInterstitial: NSObject, MediationInterstitialAd { /// The Sample Ad Network interstitial ad. var interstitial: SampleInterstitial? /// The ad event delegate to forward ad rendering events to Google Mobile Ads SDK. var delegate: MediationInterstitialAdEventDelegate? var completionHandler: GADMediationInterstitialLoadCompletionHandler? func loadInterstitial( for adConfiguration: MediationInterstitialAdConfiguration, completionHandler: @escaping GADMediationInterstitialLoadCompletionHandler ) { interstitial = SampleInterstitial.init( adUnitID: adConfiguration.credentials.settings["parameter"] as? String) interstitial?.delegate = self let adRequest = SampleAdRequest() adRequest.testMode = adConfiguration.isTestRequest self.completionHandler = completionHandler interstitial?.fetchAd(adRequest) } func present(from viewController: UIViewController) { if let interstitial = interstitial, interstitial.isInterstitialLoaded { interstitial.show() } } }
অবজেক্টিভ-সি
#import "SampleCustomEventInterstitial.h" @interface SampleCustomEventInterstitial () <SampleInterstitialAdDelegate, GADMediationInterstitialAd> { /// The sample interstitial ad. SampleInterstitial *_interstitialAd; /// The completion handler to call when the ad loading succeeds or fails. GADMediationInterstitialLoadCompletionHandler _loadCompletionHandler; /// The ad event delegate to forward ad rendering events to the Google Mobile /// Ads SDK. id <GADMediationInterstitialAdEventDelegate> _adEventDelegate; } @end - (void)loadInterstitialForAdConfiguration: (GADMediationInterstitialAdConfiguration *)adConfiguration completionHandler: (GADMediationInterstitialLoadCompletionHandler) completionHandler { __block atomic_flag completionHandlerCalled = ATOMIC_FLAG_INIT; __block GADMediationInterstitialLoadCompletionHandler originalCompletionHandler = [completionHandler copy]; _loadCompletionHandler = ^id<GADMediationInterstitialAdEventDelegate>( _Nullable id<GADMediationInterstitialAd> ad, NSError *_Nullable error) { // Only allow completion handler to be called once. if (atomic_flag_test_and_set(&completionHandlerCalled)) { return nil; } id<GADMediationInterstitialAdEventDelegate> delegate = nil; if (originalCompletionHandler) { // Call original handler and hold on to its return value. delegate = originalCompletionHandler(ad, error); } // Release reference to handler. Objects retained by the handler will also // be released. originalCompletionHandler = nil; return delegate; }; NSString *adUnit = adConfiguration.credentials.settings[@"parameter"]; _interstitialAd = [[SampleInterstitial alloc] initWithAdUnitID:adUnit]; _interstitialAd.delegate = self; SampleAdRequest *adRequest = [[SampleAdRequest alloc] init]; adRequest.testMode = adConfiguration.isTestRequest; [_interstitialAd fetchAd:adRequest]; }
 বিজ্ঞাপনটি সফলভাবে আনা হোক বা কোনও ত্রুটির সম্মুখীন হোক, আপনি GADMediationInterstitialLoadCompletionHandler কল করবেন। সফল হলে, ত্রুটি প্যারামিটারের জন্য nil মান সহ GADMediationInterstitialAd প্রয়োগকারী ক্লাসটি পাস করুন; ব্যর্থ হলে, আপনার সম্মুখীন ত্রুটিটি পাস করুন।
 সাধারণত, এই পদ্ধতিগুলি আপনার অ্যাডাপ্টার দ্বারা প্রয়োগ করা তৃতীয়-পক্ষের SDK থেকে কলব্যাকের ভিতরে প্রয়োগ করা হয়। এই উদাহরণের জন্য, Sample SDK-তে প্রাসঙ্গিক কলব্যাক সহ একটি SampleInterstitialAdDelegate রয়েছে: 
সুইফট
func interstitialDidLoad(_ interstitial: SampleInterstitial) { if let handler = completionHandler { delegate = handler(self, nil) } } func interstitial( _ interstitial: SampleInterstitial, didFailToLoadAdWith errorCode: SampleErrorCode ) { let error = SampleCustomEventUtilsSwift.SampleCustomEventErrorWithCodeAndDescription( code: SampleCustomEventErrorCodeSwift .SampleCustomEventErrorAdLoadFailureCallback, description: "Sample SDK returned an ad load failure callback with error code: \(errorCode)" ) if let handler = completionHandler { delegate = handler(nil, error) } }
অবজেক্টিভ-সি
- (void)interstitialDidLoad:(SampleInterstitial *)interstitial { _adEventDelegate = _loadCompletionHandler(self, nil); } - (void)interstitial:(SampleInterstitial *)interstitial didFailToLoadAdWithErrorCode:(SampleErrorCode)errorCode { NSError *error = SampleCustomEventErrorWithCodeAndDescription( SampleCustomEventErrorAdLoadFailureCallback, [NSString stringWithFormat:@"Sample SDK returned an ad load failure " @"callback with error code: %@", errorCode]); _adEventDelegate = _loadCompletionHandler(nil, error); }
 GADMediationInterstitialAd বিজ্ঞাপনটি প্রদর্শনের জন্য একটি present পদ্ধতি প্রয়োগ করা প্রয়োজন: 
সুইফট
func present(from viewController: UIViewController) { if let interstitial = interstitial, interstitial.isInterstitialLoaded { interstitial.show() } }
অবজেক্টিভ-সি
- (void)presentFromViewController:(UIViewController *)viewController { if ([_interstitialAd isInterstitialLoaded]) { [_interstitialAd show]; } else { NSError *error = SampleCustomEventErrorWithCodeAndDescription( SampleCustomEventErrorAdNotLoaded, [NSString stringWithFormat:@"The interstitial ad failed to present " @"because the ad was not loaded."]); [_adEventDelegate didFailToPresentWithError:error] } }
মধ্যস্থতা ইভেন্টগুলি Google মোবাইল বিজ্ঞাপন SDK-তে ফরোয়ার্ড করুন
 একবার আপনি লোড করা বিজ্ঞাপনের সাথে GADMediationInterstitialLoadCompletionHandler কল করলে, ফেরত আসা GADMediationInterstitialAdEventDelegate ডেলিগেট অবজেক্টটি অ্যাডাপ্টার দ্বারা তৃতীয় পক্ষের SDK থেকে Google Mobile Ads SDK-তে উপস্থাপনা ইভেন্টগুলি ফরোয়ার্ড করতে ব্যবহার করা যেতে পারে। SampleCustomEventInterstitial ক্লাসটি SampleInterstitialAdDelegate প্রোটোকল প্রয়োগ করে নমুনা বিজ্ঞাপন নেটওয়ার্ক থেকে Google Mobile Ads SDK-তে কলব্যাক ফরোয়ার্ড করে।
আপনার কাস্টম ইভেন্টটি যতটা সম্ভব এই কলব্যাকগুলিকে ফরোয়ার্ড করা গুরুত্বপূর্ণ, যাতে আপনার অ্যাপটি Google Mobile Ads SDK থেকে এই সমতুল্য ইভেন্টগুলি গ্রহণ করে। কলব্যাক ব্যবহারের একটি উদাহরণ এখানে দেওয়া হল:
সুইফট
func interstitialWillPresentScreen(_ interstitial: SampleInterstitial) { delegate?.willPresentFullScreenView() delegate?.reportImpression() } func interstitialWillDismissScreen(_ interstitial: SampleInterstitial) { delegate?.willDismissFullScreenView() } func interstitialDidDismissScreen(_ interstitial: SampleInterstitial) { delegate?.didDismissFullScreenView() } func interstitialWillLeaveApplication(_ interstitial: SampleInterstitial) { delegate?.reportClick() }
অবজেক্টিভ-সি
- (void)interstitialWillPresentScreen:(SampleInterstitial *)interstitial { [_adEventDelegate willPresentFullScreenView]; [_adEventDelegate reportImpression]; } - (void)interstitialWillDismissScreen:(SampleInterstitial *)interstitial { [_adEventDelegate willDismissFullScreenView]; } - (void)interstitialDidDismissScreen:(SampleInterstitial *)interstitial { [_adEventDelegate didDismissFullScreenView]; } - (void)interstitialWillLeaveApplication:(SampleInterstitial *)interstitial { [_adEventDelegate reportClick]; }
এটি ইন্টারস্টিশিয়াল বিজ্ঞাপনের জন্য কাস্টম ইভেন্ট বাস্তবায়ন সম্পূর্ণ করে। সম্পূর্ণ উদাহরণটি GitHub এ উপলব্ধ। আপনি এটি এমন একটি বিজ্ঞাপন নেটওয়ার্কের সাথে ব্যবহার করতে পারেন যা ইতিমধ্যেই সমর্থিত অথবা কাস্টম ইভেন্ট ইন্টারস্টিশিয়াল বিজ্ঞাপন প্রদর্শনের জন্য এটি পরিবর্তন করতে পারেন।