ज़रूरी शर्तें
कस्टम इवेंट का सेटअप पूरा करें.
नेटिव विज्ञापन का अनुरोध करना
जब वॉटरफ़ॉल मीडिएशन चेन में कस्टम इवेंट लाइन आइटम पहुंच जाता है, तब loadNativeAd:adConfiguration:completionHandler:
तरीके को उस क्लास के नाम पर कॉल किया जाता है जिसे आपने कस्टम इवेंट बनाते समय दिया था. इस मामले में, यह तरीका SampleCustomEvent
में है. इसके बाद, यह SampleCustomEventNative
में मौजूद loadNativeAd:adConfiguration:completionHandler:
तरीके को कॉल करता है.
नेटिव विज्ञापन का अनुरोध करने के लिए, ऐसी क्लास बनाएं या उसमें बदलाव करें जो GADMediationAdapter
और loadNativeAd:adConfiguration:completionHandler:
को लागू करती हो. अगर GADMediationAdapter
को बढ़ाने वाली कोई क्लास पहले से मौजूद है, तो loadNativeAd:adConfiguration:completionHandler:
को वहां लागू करें. इसके अलावा, GADMediationNativeAd
को लागू करने के लिए एक नई क्लास बनाएं.
कस्टम इवेंट के हमारे उदाहरण में, SampleCustomEvent
, GADMediationAdapter
इंटरफ़ेस लागू करता है. इसके बाद, यह SampleCustomEventNative
को डेलिगेट करता है.
Swift
import GoogleMobileAds class SampleCustomEvent: NSObject, MediationAdapter { fileprivate var nativeAd: SampleCustomEventNativeAd? func loadNativeAd( for adConfiguration: MediationNativeAdConfiguration, completionHandler: @escaping GADMediationNativeAdLoadCompletionHandler ) { self.nativeAd = SampleCustomEventNativeAd() self.nativeAd?.loadNativeAd( for: adConfiguration, completionHandler: completionHandler) } }
Objective-C
#import "SampleCustomEvent.h" @implementation SampleCustomEvent SampleCustomEventNativeAd *sampleNativeAd; - (void)loadNativeAdForAdConfiguration: (GADMediationNativeAdConfiguration *)adConfiguration completionHandler: (GADMediationNativeAdLoadCompletionHandler) completionHandler { sampleNative = [[SampleCustomEventNativeAd alloc] init]; [sampleNative loadNativeAdForAdConfiguration:adConfiguration completionHandler:completionHandler]; }
`SampleCustomEventNative` इन कामों के लिए ज़िम्मेदार है:
नेटिव विज्ञापन लोड हो रहा है
GADMediationNativeAd
प्रोटोकॉल लागू करना.Google Mobile Ads SDK को विज्ञापन इवेंट के कॉल बैक मिलना और उनकी रिपोर्ट करना.
AdMob के यूज़र इंटरफ़ेस में तय किया गया वैकल्पिक पैरामीटर, विज्ञापन कॉन्फ़िगरेशन में शामिल है.
इस पैरामीटर को adConfiguration.credentials.settings[@"parameter"]
के ज़रिए ऐक्सेस किया जा सकता है. यह पैरामीटर आम तौर पर, विज्ञापन यूनिट आइडेंटिफ़ायर होता है. विज्ञापन ऑब्जेक्ट को इंस्टैंटिएट करते समय, विज्ञापन नेटवर्क कंपनी के SDK टूल को इसकी ज़रूरत होती है.
Swift
class SampleCustomEventNativeAd: NSObject, MediationNativeAd { /// The Sample Ad Network native ad. var nativeAd: SampleNativeAd? /// The ad event delegate to forward ad rendering events to the Google Mobile /// Ads SDK. var delegate: MediationNativeAdEventDelegate? /// Completion handler called after ad load var completionHandler: GADMediationNativeLoadCompletionHandler? func loadNativeAd( for adConfiguration: MediationNativeAdConfiguration, completionHandler: @escaping GADMediationNativeLoadCompletionHandler ) { let adLoader = SampleNativeAdLoader() let sampleRequest = SampleNativeAdRequest() // Google Mobile Ads SDK requires the image assets to be downloaded // automatically unless the publisher specifies otherwise by using the // GADNativeAdImageAdLoaderOptions object's disableImageLoading property. If // your network doesn't have an option like this and instead only ever // returns URLs for images (rather than the images themselves), your adapter // should download image assets on behalf of the publisher. This should be // done after receiving the native ad object from your network's SDK, and // before calling the connector's adapter:didReceiveMediatedNativeAd: method. sampleRequest.shouldDownloadImages = true sampleRequest.preferredImageOrientation = NativeAdImageOrientation.any sampleRequest.shouldRequestMultipleImages = false let options = adConfiguration.options for loaderOptions: AdLoaderOptions in options { if let imageOptions = loaderOptions as? NativeAdImageAdLoaderOptions { sampleRequest.shouldRequestMultipleImages = imageOptions.shouldRequestMultipleImages // If the GADNativeAdImageAdLoaderOptions' disableImageLoading property is // YES, the adapter should send just the URLs for the images. sampleRequest.shouldDownloadImages = !imageOptions.disableImageLoading } else if let mediaOptions = loaderOptions as? NativeAdMediaAdLoaderOptions { switch mediaOptions.mediaAspectRatio { case MediaAspectRatio.landscape: sampleRequest.preferredImageOrientation = NativeAdImageOrientation.landscape case MediaAspectRatio.portrait: sampleRequest.preferredImageOrientation = NativeAdImageOrientation.portrait default: sampleRequest.preferredImageOrientation = NativeAdImageOrientation.any } } } // This custom event uses the server parameter to carry an ad unit ID, which // is the most common use case. adLoader.delegate = self adLoader.adUnitID = adConfiguration.credentials.settings["parameter"] as? String self.completionHandler = completionHandler adLoader.fetchAd(sampleRequest) } }
Objective-C
#import "SampleCustomEventNativeAd.h" @interface SampleCustomEventNativeAd () <SampleNativeAdDelegate, GADMediationNativeAd> { /// The sample native ad. SampleNativeAd *_nativeAd; /// The completion handler to call when the ad loading succeeds or fails. GADMediationNativeLoadCompletionHandler _loadCompletionHandler; /// The ad event delegate to forward ad rendering events to the Google Mobile /// Ads SDK. id<GADMediationNativeAdEventDelegate> _adEventDelegate; } @end - (void)loadNativeAdForAdConfiguration: (GADMediationNativeAdConfiguration *)adConfiguration completionHandler:(GADMediationNativeLoadCompletionHandler) completionHandler { __block atomic_flag completionHandlerCalled = ATOMIC_FLAG_INIT; __block GADMediationNativeLoadCompletionHandler originalCompletionHandler = [completionHandler copy]; _loadCompletionHandler = ^id<GADMediationNativeAdEventDelegate>( _Nullable id<GADMediationNativeAd> ad, NSError *_Nullable error) { // Only allow completion handler to be called once. if (atomic_flag_test_and_set(&completionHandlerCalled)) { return nil; } id<GADMediationNativeAdEventDelegate> 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; }; SampleNativeAdLoader *adLoader = [[SampleNativeAdLoader alloc] init]; SampleNativeAdRequest *sampleRequest = [[SampleNativeAdRequest alloc] init]; // Google Mobile Ads SDK requires the image assets to be downloaded // automatically unless the publisher specifies otherwise by using the // GADNativeAdImageAdLoaderOptions object's disableImageLoading property. If // your network doesn't have an option like this and instead only ever returns // URLs for images (rather than the images themselves), your adapter should // download image assets on behalf of the publisher. This should be done after // receiving the native ad object from your network's SDK, and before calling // the connector's adapter:didReceiveMediatedNativeAd: method. sampleRequest.shouldDownloadImages = YES; sampleRequest.preferredImageOrientation = NativeAdImageOrientationAny; sampleRequest.shouldRequestMultipleImages = NO; sampleRequest.testMode = adConfiguration.isTestRequest; for (GADAdLoaderOptions *loaderOptions in adConfiguration.options) { if ([loaderOptions isKindOfClass:[GADNativeAdImageAdLoaderOptions class]]) { GADNativeAdImageAdLoaderOptions *imageOptions = (GADNativeAdImageAdLoaderOptions *)loaderOptions; sampleRequest.shouldRequestMultipleImages = imageOptions.shouldRequestMultipleImages; // If the GADNativeAdImageAdLoaderOptions' disableImageLoading property is // YES, the adapter should send just the URLs for the images. sampleRequest.shouldDownloadImages = !imageOptions.disableImageLoading; } else if ([loaderOptions isKindOfClass:[GADNativeAdMediaAdLoaderOptions class]]) { GADNativeAdMediaAdLoaderOptions *mediaOptions = (GADNativeAdMediaAdLoaderOptions *)loaderOptions; switch (mediaOptions.mediaAspectRatio) { case GADMediaAspectRatioLandscape: sampleRequest.preferredImageOrientation = NativeAdImageOrientationLandscape; break; case GADMediaAspectRatioPortrait: sampleRequest.preferredImageOrientation = NativeAdImageOrientationPortrait; break; default: sampleRequest.preferredImageOrientation = NativeAdImageOrientationAny; break; } } else if ([loaderOptions isKindOfClass:[GADNativeAdViewAdOptions class]]) { _nativeAdViewAdOptions = (GADNativeAdViewAdOptions *)loaderOptions; } } // This custom event uses the server parameter to carry an ad unit ID, which // is the most common use case. NSString *adUnit = adConfiguration.credentials.settings[@"parameter"]; adLoader.adUnitID = adUnit; adLoader.delegate = self; [adLoader fetchAd:sampleRequest]; }
विज्ञापन फ़ेच हो गया है या उसमें कोई गड़बड़ी हुई है, आपको GADMediationNativeAdLoadCompletionHandler
को कॉल करना होगा. अगर अनुरोध पूरा हो जाता है, तो GADMediationNativeAd
को लागू करने वाली क्लास को nil
वैल्यू के साथ पास करें. ऐसा error पैरामीटर के लिए करें. अगर अनुरोध पूरा नहीं होता है, तो आपको जो गड़बड़ी मिली है उसे पास करें.
आम तौर पर, इन तरीकों को तीसरे पक्ष के एसडीके से मिले कॉलबैक के अंदर लागू किया जाता है. यह एसडीके, आपका अडैप्टर लागू करता है. इस उदाहरण के लिए, Sample SDK में काम के कॉलबैक के साथ SampleNativeAdDelegate
मौजूद है:
Swift
func adLoader( _ adLoader: SampleNativeAdLoader, didReceive nativeAd: SampleNativeAd ) { extraAssets = [ SampleCustomEventConstantsSwift.awesomenessKey: nativeAd.degreeOfAwesomeness ?? "" ] if let image = nativeAd.image { images = [NativeAdImage(image: image)] } else { let imageUrl = URL(fileURLWithPath: nativeAd.imageURL) images = [NativeAdImage(url: imageUrl, scale: nativeAd.imageScale)] } if let mappedIcon = nativeAd.icon { icon = NativeAdImage(image: mappedIcon) } else { let iconURL = URL(fileURLWithPath: nativeAd.iconURL) icon = NativeAdImage(url: iconURL, scale: nativeAd.iconScale) } adChoicesView = SampleAdInfoView() self.nativeAd = nativeAd if let handler = completionHandler { delegate = handler(self, nil) } } func adLoader( _ adLoader: SampleNativeAdLoader, 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) } }
Objective-C
- (void)adLoader:(SampleNativeAdLoader *)adLoader didReceiveNativeAd:(SampleNativeAd *)nativeAd { if (nativeAd.image) { _images = @[ [[GADNativeAdImage alloc] initWithImage:nativeAd.image] ]; } else { NSURL *imageURL = [[NSURL alloc] initFileURLWithPath:nativeAd.imageURL]; _images = @[ [[GADNativeAdImage alloc] initWithURL:imageURL scale:nativeAd.imageScale] ]; } if (nativeAd.icon) { _icon = [[GADNativeAdImage alloc] initWithImage:nativeAd.icon]; } else { NSURL *iconURL = [[NSURL alloc] initFileURLWithPath:nativeAd.iconURL]; _icon = [[GADNativeAdImage alloc] initWithURL:iconURL scale:nativeAd.iconScale]; } // The sample SDK provides an AdChoices view (SampleAdInfoView). If your SDK // provides image and click through URLs for its AdChoices icon instead of an // actual UIView, the adapter is responsible for downloading the icon image // and creating the AdChoices icon view. _adChoicesView = [[SampleAdInfoView alloc] init]; _nativeAd = nativeAd; _adEventDelegate = _loadCompletionHandler(self, nil); } - (void)adLoader:(SampleNativeAdLoader *)adLoader 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); }
मैप पर दिखने वाले नेटिव विज्ञापन
अलग-अलग SDK में, नेटिव विज्ञापनों के लिए अपने यूनीक फ़ॉर्मैट होते हैं. ऐसा हो सकता है कि एक ऑब्जेक्ट में "title" फ़ील्ड हो, जबकि दूसरे में "headline" फ़ील्ड हो. इसके अलावा, इंप्रेशन को ट्रैक करने और क्लिक को प्रोसेस करने के लिए इस्तेमाल किए जाने वाले तरीके, एक एसडीके से दूसरे एसडीके में अलग-अलग हो सकते हैं.
इन समस्याओं को हल करने के लिए, जब किसी कस्टम इवेंट को मीडिएट किए गए SDK टूल से नेटिव विज्ञापन ऑब्जेक्ट मिलता है, तो उसे GADMediationNativeAd
को लागू करने वाली क्लास का इस्तेमाल करना चाहिए. जैसे, SampleCustomEventNativeAd
. ऐसा इसलिए, ताकि मीडिएट किए गए SDK टूल के नेटिव विज्ञापन ऑब्जेक्ट को "मैप" किया जा सके. इससे वह Google Mobile Ads SDK के इंटरफ़ेस से मैच हो जाएगा.
अब हम SampleCustomEventNativeAd
को लागू करने से जुड़ी जानकारी के बारे में ज़्यादा जानकारी देते हैं.
अपनी मैपिंग सेव करना
GADMediationNativeAd
को कुछ ऐसी प्रॉपर्टी लागू करनी होंगी जिन्हें अन्य एसडीके की प्रॉपर्टी से मैप किया गया है:
Swift
var nativeAd: SampleNativeAd? var headline: String? { return nativeAd?.headline } var images: [NativeAdImage]? var body: String? { return nativeAd?.body } var icon: NativeAdImage? var callToAction: String? { return nativeAd?.callToAction } var starRating: NSDecimalNumber? { return nativeAd?.starRating } var store: String? { return nativeAd?.store } var price: String? { return nativeAd?.price } var advertiser: String? { return nativeAd?.advertiser } var extraAssets: [String: Any]? { return [ SampleCustomEventConstantsSwift.awesomenessKey: nativeAd?.degreeOfAwesomeness ?? "" ] } var adChoicesView: UIView? var mediaView: UIView? { return nativeAd?.mediaView }
Objective-C
/// Used to store the ad's images. In order to implement the /// GADMediationNativeAd protocol, we use this class to return the images /// property. NSArray<GADNativeAdImage *> *_images; /// Used to store the ad's icon. In order to implement the GADMediationNativeAd /// protocol, we use this class to return the icon property. GADNativeAdImage *_icon; /// Used to store the ad's ad choices view. In order to implement the /// GADMediationNativeAd protocol, we use this class to return the adChoicesView /// property. UIView *_adChoicesView; - (nullable NSString *)headline { return _nativeAd.headline; } - (nullable NSArray<GADNativeAdImage *> *)images { return _images; } - (nullable NSString *)body { return _nativeAd.body; } - (nullable GADNativeAdImage *)icon { return _icon; } - (nullable NSString *)callToAction { return _nativeAd.callToAction; } - (nullable NSDecimalNumber *)starRating { return _nativeAd.starRating; } - (nullable NSString *)store { return _nativeAd.store; } - (nullable NSString *)price { return _nativeAd.price; } - (nullable NSString *)advertiser { return _nativeAd.advertiser; } - (nullable NSDictionary<NSString *, id> *)extraAssets { return @{SampleCustomEventExtraKeyAwesomeness : _nativeAd.degreeOfAwesomeness}; } - (nullable UIView *)adChoicesView { return _adChoicesView; } - (nullable UIView *)mediaView { return _nativeAd.mediaView; } - (BOOL)hasVideoContent { return self.mediaView != nil; }
मीडिएशन की सुविधा देने वाले कुछ नेटवर्क, Google Mobile Ads SDK की ओर से तय की गई ऐसेट के अलावा अन्य ऐसेट भी उपलब्ध करा सकते हैं. GADMediationNativeAd
प्रोटोकॉल में एक तरीका शामिल है, जिसे extraAssets
कहा जाता है. Google Mobile Ads SDK इसका इस्तेमाल, आपके मैपर से इनमें से किसी भी "अतिरिक्त" ऐसेट को वापस पाने के लिए करता है.
मैप इमेज ऐसेट
इमेज ऐसेट को मैप करना, NSString
या double
जैसे आसान डेटा टाइप को मैप करने से ज़्यादा मुश्किल है. इमेज अपने-आप डाउनलोड हो सकती हैं या यूआरएल वैल्यू के तौर पर दिख सकती हैं. इनकी पिक्सल डेंसिटी भी अलग-अलग हो सकती है.
इस जानकारी को मैनेज करने के लिए, Google Mobile Ads SDK GADNativeAdImage
क्लास उपलब्ध कराता है. इमेज ऐसेट की जानकारी (चाहे वह असल UIImage
ऑब्जेक्ट हो या सिर्फ़ NSURL
वैल्यू) को इस क्लास का इस्तेमाल करके, Google Mobile Ads SDK को वापस भेजा जाना चाहिए.
यहां बताया गया है कि मैपर क्लास, आइकॉन इमेज को सेव करने के लिए GADNativeAdImage
को कैसे बनाता है:
Swift
if let image = nativeAd.image { images = [NativeAdImage(image: image)] } else { let imageUrl = URL(fileURLWithPath: nativeAd.imageURL) images = [NativeAdImage(url: imageUrl, scale: nativeAd.imageScale)] }
Objective-C
if (nativeAd.image) { _images = @[ [[GADNativeAdImage alloc] initWithImage:nativeAd.image] ]; } else { NSURL *imageURL = [[NSURL alloc] initFileURLWithPath:nativeAd.imageURL]; _images = @[ [[GADNativeAdImage alloc] initWithURL:imageURL scale:nativeAd.imageScale] ]; }
इंप्रेशन और क्लिक इवेंट
Google Mobile Ads SDK और मीडिएट किए गए SDK, दोनों को यह पता होना चाहिए कि इंप्रेशन या क्लिक कब हुआ. हालांकि, सिर्फ़ एक SDK को इन इवेंट को ट्रैक करना चाहिए. कस्टम इवेंट को दो अलग-अलग तरीकों से इस्तेमाल किया जा सकता है. यह इस बात पर निर्भर करता है कि मीडिएट किए गए SDK टूल में, इंप्रेशन और क्लिक को अपने-आप ट्रैक करने की सुविधा है या नहीं.
Google Mobile Ads SDK की मदद से क्लिक और इंप्रेशन ट्रैक करना
अगर मीडिएट किया गया SDK, इंप्रेशन और क्लिक को खुद ट्रैक नहीं करता है, लेकिन क्लिक और इंप्रेशन रिकॉर्ड करने के तरीके उपलब्ध कराता है, तो Google Mobile Ads SDK इन इवेंट को ट्रैक कर सकता है और अडैप्टर को इसकी सूचना दे सकता है. GADMediationNativeAd
प्रोटोकॉल में दो तरीके शामिल हैं: didRecordImpression:
और didRecordClickOnAssetWithName:view:viewController:
. कस्टम इवेंट, इन तरीकों को लागू करके, मीडिएट किए गए नेटिव विज्ञापन ऑब्जेक्ट पर संबंधित तरीके को कॉल कर सकते हैं:
Swift
func didRecordImpression() { nativeAd?.recordImpression() } func didRecordClickOnAsset( withName assetName: GADUnifiedNativeAssetIdentifier, view: UIView, wController: UIViewController ) { nativeAd?.handleClick(on: view) }
Objective-C
- (void)didRecordImpression { if (self.nativeAd) { [self.nativeAd recordImpression]; } } - (void)didRecordClickOnAssetWithName:(GADUnifiedNativeAssetIdentifier)assetName view:(UIView *)view viewController:(UIViewController *)viewController { if (self.nativeAd) { [self.nativeAd handleClickOnView:view]; } }
GADMediationNativeAd
प्रोटोकॉल लागू करने वाली क्लास, Sample SDK के नेटिव विज्ञापन ऑब्जेक्ट का रेफ़रंस रखती है. इसलिए, वह क्लिक या इंप्रेशन की रिपोर्ट करने के लिए, उस ऑब्जेक्ट पर सही तरीके से कॉल कर सकती है. ध्यान दें कि didRecordClickOnAssetWithName:view:viewController:
तरीके में सिर्फ़ एक पैरामीटर होता है: View
ऑब्जेक्ट. यह ऑब्जेक्ट, उस नेटिव विज्ञापन ऐसेट से जुड़ा होता है जिसे क्लिक मिला है.
मीडिएट किए गए एसडीके की मदद से क्लिक और इंप्रेशन ट्रैक करना
ऐसा हो सकता है कि कुछ मीडिएटेड SDK, क्लिक और इंप्रेशन को खुद ट्रैक करना चाहें. ऐसे में, आपको handlesUserClicks
और handlesUserImpressions
तरीकों को लागू करना चाहिए. इसके बारे में यहां दिए गए स्निपेट में बताया गया है. YES
को वापस लाने का मतलब है कि कस्टम इवेंट, इन इवेंट को ट्रैक करने की ज़िम्मेदारी लेता है. साथ ही, इन इवेंट के होने पर Google Mobile Ads SDK को सूचना देगा.
क्लिक और इंप्रेशन ट्रैकिंग को बदलने वाले कस्टम इवेंट, didRenderInView:
मैसेज का इस्तेमाल करके, मीडिएट किए गए SDK टूल के नेटिव विज्ञापन ऑब्जेक्ट को नेटिव विज्ञापन का व्यू पास कर सकते हैं. इससे मीडिएट किए गए SDK टूल को असल ट्रैकिंग करने की अनुमति मिलती है. कस्टम इवेंट के उदाहरण वाले प्रोजेक्ट से लिए गए सैंपल SDK टूल में, इस तरीके का इस्तेमाल नहीं किया गया है. इस गाइड के कोड स्निपेट भी इसी प्रोजेक्ट से लिए गए हैं. हालांकि, अगर इस तरीके का इस्तेमाल किया जाता, तो कस्टम इवेंट कोड, setNativeAdView:view:
तरीके को कॉल करता. जैसा कि यहां दिए गए स्निपेट में दिखाया गया है:
Swift
func handlesUserClicks() -> Bool { return true } func handlesUserImpressions() -> Bool { return true } func didRender( in view: UIView, clickableAssetViews: [GADNativeAssetIdentifier: UIView], nonclickableAssetViews: [GADNativeAssetIdentifier: UIView], viewController: UIViewController ) { // This method is called when the native ad view is rendered. Here you would pass the UIView // back to the mediated network's SDK. self.nativeAd?.setNativeAdView(view) }
Objective-C
- (BOOL)handlesUserClicks { return YES; } - (BOOL)handlesUserImpressions { return YES; } - (void)didRenderInView:(UIView *)view clickableAssetViews:(NSDictionary<GADNativeAssetIdentifier, UIView *> *) clickableAssetViews nonclickableAssetViews:(NSDictionary<GADNativeAssetIdentifier, UIView *> *) nonclickableAssetViews viewController:(UIViewController *)viewController { // This method is called when the native ad view is rendered. Here you would // pass the UIView back to the mediated network's SDK. Playing video using // SampleNativeAd's playVideo method [_nativeAd setNativeAdView:view]; }
मीडिएशन इवेंट को Google Mobile Ads SDK पर फ़ॉरवर्ड करना
विज्ञापन लोड होने के बाद, GADMediationNativeLoadCompletionHandler
को कॉल करने पर, दिखाए गए GADMediationNativeAdEventDelegate
डेलिगेट ऑब्जेक्ट का इस्तेमाल अडैप्टर कर सकता है. इससे तीसरे पक्ष के एसडीके से Google Mobile Ads SDK को प्रज़ेंटेशन इवेंट फ़ॉरवर्ड किए जा सकते हैं.
यह ज़रूरी है कि आपका कस्टम इवेंट, इनमें से ज़्यादा से ज़्यादा कॉलबैक फ़ॉरवर्ड करे, ताकि आपके ऐप्लिकेशन को Google Mobile Ads SDK से मिलते-जुलते इवेंट मिल सकें. यहां कॉलबैक इस्तेमाल करने का एक उदाहरण दिया गया है:
इससे नेटिव विज्ञापनों के लिए कस्टम इवेंट लागू करने की प्रोसेस पूरी हो जाती है. पूरा उदाहरण GitHub पर उपलब्ध है.