इस पेज पर, iOS के लिए Google Mobile Ads SDK के मौजूदा और पिछले वर्शन के माइग्रेशन के बारे में बताया गया है. वर्शन 12.0.0, फ़रवरी 2025 में रिलीज़ किया जा सकता है.
SDK टूल के वर्शन v11 से v12 पर माइग्रेट करना
Xcode 16.0 पर अपग्रेड करें
Xcode के कम से कम ज़रूरी वर्शन को बढ़ाकर 16.0 कर दिया गया है.
Swift के नाम रखने के नियमों के मुताबिक नाम रखने की सुविधा
वर्शन 12.0.0 में, Swift API डिज़ाइन के दिशा-निर्देशों में बताए गए नाम रखने के नियमों का पालन करने के लिए बदलाव किए गए हैं. इन बदलावों का असर सिर्फ़ Swift पर पड़ता है. Objective-C API के नाम में कोई बदलाव नहीं किया गया है.
क्लास के प्रीफ़िक्स में बदलाव
क्लास के प्रीफ़िक्स में ये बदलाव किए गए हैं:
- सभी टाइप के नामों से
GAD
प्रीफ़िक्स हटाया गया. GAM
प्रीफ़िक्स का नाम बदलकरAdManager
कर दिया गया है.GADM
प्रीफ़िक्स का नाम बदलकरMediation
कर दिया गया है.
गड़बड़ियां ठीक करना
इन बदलावों की वजह से होने वाली गड़बड़ियों को ठीक करने का सबसे सही तरीका है कि आप 'इसे ठीक करें' सुविधा का इस्तेमाल करके सुधार करें.
नाम से जुड़े विवादों को हल करना
नामों के टकराव को हल करने के लिए, मॉड्यूल की ओर से दिए गए नेमस्पेस का इस्तेमाल करें. उदाहरण के लिए, GADRequest
का नाम बदलकर अब Request
कर दिया गया है. यहां Google Mobile Ads SDK Request
क्लास के नेमस्पेस का उदाहरण दिया गया है:
import GoogleMobileAds
...
var request: GoogleMobileAds.Request?
Swift में किए गए बदलावों की पूरी सूची
यहां दी गई टेबल में, Swift API में किए गए बदलावों के बारे में बताया गया है:
वर्शन 11 | वर्शन 12 |
---|---|
GADAdapterInitializationState |
AdapterInitializationState |
GADAdChoicesPosition |
AdChoicesPosition |
GADAdChoicesView |
AdChoicesView |
GADAdFormat |
AdFormat |
GADAdLoader |
AdLoader |
GADAdLoaderAdType |
AdLoaderAdType |
GADAdLoaderDelegate |
AdLoaderDelegate |
GADAdMetadataDelegate |
AdMetadataDelegate |
GADAdMetadataProvider |
AdMetadataProvider |
GADAdNetworkExtras |
AdNetworkExtras |
GADAdNetworkResponseInfo |
AdNetworkResponseInfo |
GADAdReward |
AdReward |
GADAdSize |
AdSize |
GADAdSizeDelegate |
AdSizeDelegate |
GADAdValue |
AdValue |
GADAdValuePrecision |
AdValuePrecision |
GADAppEventDelegate |
AppEventDelegate |
GADAppOpenAd |
AppOpenAd |
GADAppOpenSignalRequest |
AppOpenSignalRequest |
GADAudioVideoManager |
AudioVideoManager |
GADAudioVideoManagerDelegate |
AudioVideoManagerDelegate |
GADBannerSignalRequest |
BannerSignalRequest |
GADBannerView |
BannerView |
GADBannerViewDelegate |
BannerViewDelegate |
GADCustomEventExtras |
CustomEventExtras |
GADCustomEventRequest |
CustomEventRequest |
GADCustomNativeAd |
CustomNativeAd |
GADCustomNativeAdLoaderDelegate |
CustomNativeAdLoaderDelegate |
GADCustomNativeAdDelegate |
CustomNativeAdDelegate |
GADDebugOptionsViewControllerDelegate |
DebugOptionsViewControllerDelegate |
GADDebugOptionsViewController |
DebugOptionsViewController |
GADDisplayAdMeasurement |
DisplayAdMeasurement |
GADExtras |
Extras |
GADFullScreenPresentingAd |
FullScreenPresentingAd |
GADFullScreenContentDelegate |
FullScreenContentDelegate |
GADAdapterStatus |
AdapterStatus |
GADInitializationStatus |
InitializationStatus |
GADInterstitialAd |
InterstitialAd |
GADInterstitialSignalRequest |
InterstitialSignalRequest |
GADMediaAspectRatio |
MediaAspectRatio |
GADMediaContent |
MediaContent |
GADMediaView |
MediaView |
GADMobileAds |
MobileAds |
GADMultipleAdsAdLoaderOptions |
MultipleAdsAdLoaderOptions |
GADMuteThisAdReason |
MuteThisAdReason |
GADNativeAd |
NativeAd |
GADNativeAdLoaderDelegate |
NativeAdLoaderDelegate |
GADNativeAdView |
NativeAdView |
GADNativeAdCustomClickGestureOptions |
NativeAdCustomClickGestureOptions |
GADNativeAdDelegate |
NativeAdDelegate |
GADNativeAdImage |
NativeAdImage |
GADNativeAdImageAdLoaderOptions |
NativeAdImageAdLoaderOptions |
GADNativeAdInlineBehavior |
NativeAdInlineBehavior |
GADNativeAdInlineBehaviorOptions |
NativeAdInlineBehaviorOptions |
GADNativeAdMediaAdLoaderOptions |
NativeAdMediaAdLoaderOptions |
GADNativeAdUnconfirmedClickDelegate |
NativeAdUnconfirmedClickDelegate |
GADNativeAdViewAdOptions |
NativeAdViewAdOptions |
GADNativeMuteThisAdLoaderOptions |
NativeMuteThisAdLoaderOptions |
GADNativeSignalRequest |
NativeSignalRequest |
GADPresentationError |
PresentationError |
GADPublisherPrivacyPersonalizationState |
PublisherPrivacyPersonalizationState |
GADQueryInfo |
QueryInfo |
GADRequest |
Request |
GADRequestError |
RequestError |
GADRequestConfiguration |
RequestConfiguration |
GADResponseInfo |
ResponseInfo |
GADRewardedAd |
RewardedAd |
GADRewardedSignalRequest |
RewardedSignalRequest |
GADRewardedInterstitialAd |
RewardedInterstitialAd |
GADRewardedInterstitialSignalRequest |
RewardedInterstitialSignalRequest |
GADSearchBannerView |
SearchBannerView |
GADServerSideVerificationOptions |
ServerSideVerificationOptions |
GADSignal |
Signal |
GADSignalRequest |
SignalRequest |
GADVersionNumber |
VersionNumber |
GADVideoController |
VideoController |
GADVideoControllerDelegate |
VideoControllerDelegate |
Ad Manager | |
GAMBannerAdLoaderDelegate |
AdManagerBannerAdLoaderDelegate |
GAMBannerView |
AdManagerBannerView |
GAMBannerViewOptions |
AdManagerBannerViewOptions |
GAMInterstitialAd |
AdManagerInterstitialAd |
GAMRequest |
AdManagerRequest |
मीडिएशन | |
GADMAdNetworkAdapter |
MediationAdNetworkAdapter |
GADMAdNetworkConnector |
MediationAdNetworkConnector |
GADMBannerAnimationType |
MediationBannerAnimationType |
GADMediatedUnifiedNativeAd |
MediationUnifiedNativeAd |
GADMediatedUnifiedNativeAdNotificationSource |
MediationUnifiedNativeAdNotificationSource |
GADMediationAd |
MediationAd |
GADMediationAdConfiguration |
MediationAdConfiguration |
GADMediationAdEventDelegate |
MediationAdEventDelegate |
GADMediationAdRequest |
MediationAdRequest |
GADMediationAdapter |
MediationAdapter |
GADMediationAppOpenAd |
MediationAppOpenAd |
GADMediationAppOpenAdEventDelegate |
MediationAppOpenAdEventDelegate |
GADMediationBannerAd |
MediationBannerAd |
GADMediationBannerAdConfiguration |
MediationBannerAdConfiguration |
GADMediationBannerAdEventDelegate |
MediationBannerAdEventDelegate |
GADMediationCredentials |
MediationCredentials |
GADMediationInterstitialAd |
MediationInterstitialAd |
GADMediationInterstitialAdConfiguration |
MediationInterstitialAdConfiguration |
GADMediationInterstitialAdEventDelegate |
MediationInterstitialAdEventDelegate |
GADMediationNativeAd |
MediationNativeAd |
GADMediationNativeAdConfiguration |
MediationNativeAdConfiguration |
GADMediationNativeAdEventDelegate |
MediationNativeAdEventDelegate |
GADMediationRewardedAd |
MediationRewardedAd |
GADMediationRewardedAdConfiguration |
MediationRewardedAdConfiguration |
GADMediationRewardedAdEventDelegate |
MediationRewardedAdEventDelegate |
GADMediationServerConfiguration |
MediationServerConfiguration |
रीयल-टाइम बोली-प्रक्रिया | |
GADRTBAdapter |
RTBAdapter |
GADRTBMediationSignalsConfiguration |
RTBMediationSignalsConfiguration |
GADRTBRequestParameters |
RTBRequestParameters |
कॉन्स्टेंट
वर्शन 11 | वर्शन 12 |
---|---|
GADAdLoaderAdType.gamBanner |
AdLoaderAdType.adManagerBanner |
GADAdSizeBanner |
AdSizeBanner |
GADAdSizeFluid |
AdSizeFluid |
GADAdSizeFullBanner |
AdSizeFullBanner |
GADAdSizeInvalid |
AdSizeInvalid |
GADAdSizeLargeBanner |
AdSizeLargeBanner |
GADAdSizeLeaderboard |
AdSizeLeaderboard |
GADAdSizeMediumRectangle |
AdSizeMediumRectangle |
GADAdSizeSkyscraper |
AdSizeSkyscraper |
GoogleMobileAdsVersionString |
GoogleMobileAdsVersion |
प्रॉपर्टी
टाइप | वर्शन 11 | वर्शन 12 |
---|---|---|
GADAdLoader | loading |
isLoading |
GADAudioVideoManager | audioSessionApplicationManaged |
isAudioSessionApplicationManaged |
GADBannerView | autoloadEnabled |
isAutoloadEnabled |
GADMobileAds | sharedInstance |
shared |
applicationMuted |
isApplicationMuted |
|
GADMuteThisAdReason | reasonDescription |
reason |
GADNativeAd | customMuteThisAdAvailable |
isCustomMuteThisAdAvailable |
GADNativeAdCustomClickGestureOptions | tapsAllowed |
areTapsAllowed |
GADNativeAdImageAdLoaderOptions | imageLoadingDisabled |
isImageLoadingDisabled |
GADNativeMuteThisAdLoaderOptions | customMuteThisAdRequested |
isCustomMuteThisAdRequested |
GADNativeSignalRequest | imageLoadingDisabled |
isImageLoadingDisabled |
customMuteThisAdRequested |
isCustomMuteThisAdRequested |
|
GADRequest | neighboringContentURLStrings |
neighboringContentURLs |
GADResponseInfo | extrasDictionary |
extras |
GADServerSideVerificationOptions | customRewardString |
customRewardText |
GADSignal | signalString |
signal |
GADSignalRequest | neighboringContentURLStrings |
neighboringContentURLs |
GADVideoController | customControlsRequested |
areCustomControlsRequested |
clickToExpandEnabled |
isClickToExpandEnabled |
|
GADVideoOptions | startMuted |
shouldStartMuted |
customControlsRequested |
areCustomControlsRequested |
|
clickToExpandRequested |
isClickToExpandRequested |
फ़ंक्शन
टाइप | वर्शन 11 | वर्शन 12 |
---|---|---|
GADAdSize | GADPortraitInlineAdaptiveBannerAdSizeWithWidth(_:) |
portraitInlineAdaptiveBanner(width:) |
GADLandscapeInlineAdaptiveBannerAdSizeWithWidth(_:) |
landscapeInlineAdaptiveBanner(width:) |
|
GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(_:) |
currentOrientationInlineAdaptiveBanner(width:) |
|
GADInlineAdaptiveBannerAdSizeWithWidthAndMaxHeight(_:, _:) |
inlineAdaptiveBanner(width:maxHeight:) |
|
GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(_:) |
portraitAnchoredAdaptiveBanner(width:) |
|
GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(_:) |
landscapeAnchoredAdaptiveBanner(width:) |
|
GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(_:) |
currentOrientationAnchoredAdaptiveBanner(width:) |
|
GADAdSizeFromCGSize(_:) |
adSizeFor(cgSize:) |
|
GADAdSizeFullWidthPortraitWithHeight(_:) |
fullWidthPortrait(height:) |
|
GADAdSizeFullWidthLandscapeWithHeight(_:) |
fullWidthLandscape(height:) |
|
GADAdSizeEqualToSize(_:, _:) |
isAdSizeEqualToSize(size1:size2:) |
|
IsGADAdSizeValid(_:) |
isAdSizeValid(size:) |
|
GADAdSizeIsFluid(_:) |
isAdSizeFluid(size:) |
|
CGSizeFromGADAdSize(_:) |
cgSize(for:) |
|
NSStringFromGADAdSize(_:) |
string(for:) |
|
NSValueFromGADAdSize(_:) |
nsValue(for:) |
|
GADAdSizeFromNSValue(_:) |
adSizeFor(nsValue:) |
|
GADClosestValidSizeForAdSizes(_:_:) |
closestValidSizeForAdSizes(original:possibleAdSizes:) |
|
GADAppEventDelegate | adView(_:didReceiveAppEvent:withInfo:) |
adView(_:didReceiveAppEvent:with:) |
interstitialAd(_:didReceiveAppEvent:withInfo:) |
adView(_:didReceiveAppEvent:with:) |
|
GADAppOpenAd | load(withAdResponseString:) |
load(with:) |
load(withAdUnitID:request:completionHandler:) |
load(with:request:completionHandler:) |
|
canPresent(fromRootViewController:) |
canPresent(from:) |
|
present(fromRootViewController:) |
present(from:) |
|
GADBannerView | load(withAdResponseString:) |
load(with:) |
GADInterstitial | load(withAdResponseString:) |
load(with:) |
load(withAdUnitID:request:completionHandler:) |
load(with:request:completionHandler:) |
|
canPresent(fromRootViewController:) |
canPresent(from:) |
|
present(fromRootViewController:) |
present(from:) |
|
GADRewardedAd | load(withAdResponseString:) |
load(with:) |
load(withAdUnitID:request:completionHandler:) |
load(with:request:completionHandler:) |
|
canPresent(fromRootViewController:) |
canPresent(from:) |
|
present(fromRootViewController:userDidEarnRewardHandler:) |
present(from:userDidEarnRewardHandler:) |
|
GADRewardedInterstitialAd | load(withAdResponseString:) |
load(with:) |
load(withAdUnitID:request:completionHandler:) |
load(with:request:completionHandler:) |
|
canPresent(fromRootViewController:) |
canPresent(from:) |
|
present(fromRootViewController:userDidEarnRewardHandler:) |
present(from:userDidEarnRewardHandler:) |
|
GADVersionNumber | GADGetStringFromVersionNumber(_ version: GADVersionNumber) |
string(for:) |
मीडिएशन | ||
GADMAdNetworkAdapter | getBannerWith(_:) |
getBanner(with:) |
presentInterstitial(fromRootViewController:) |
presentInterstitial(from:) |
|
getNativeAd(withAdTypes:options:) |
getNativeAd(with:options:) |
|
GADMediatedUnifiedNativeAd | didRecordClickOnAsset(withName:view:viewController:) |
didRecordClickOnAsset(with:view:viewController:) |
GADMediationAdapter | setUpWith(_:completionHandler:) |
setUp(with:completionHandler:) |
GADMediationAdSize | present(fromRootViewController:) |
present(from:) |
GADMediationAppOpenAd | present(fromRootViewController:) |
present(from:) |
GADMediationInterstitialAd | present(fromRootViewController:) |
present(from:) |
GADMediationRewardedAd | present(fromRootViewController:) |
present(from:) |
GAMInterstitialAd | load(withAdManagerAdUnitID:request:completionHandler:) |
load(with:request:completionHandler:) |
वीडियो को म्यूट करने की स्थिति को कंट्रोल करने के लिए एपीआई में हुए बदलाव
GADVideoController
पर मौजूद isMuted
प्रॉपर्टी और setMute:
तरीके को muted
प्रॉपर्टी से बदल दिया गया है.
इनलाइन अडैप्टिव विज्ञापनों में बदलाव
स्पेस का बेहतर तरीके से इस्तेमाल करने के लिए, इनलाइन अडैप्टिव विज्ञापन शुरू में फ़्रेम में कोई जगह नहीं लेते हैं. अब CGSizeFromGADAdSize(_:)
को अडैप्टिव विज्ञापन के इनलाइन साइज़ के साथ कॉल करने पर, Google Mobile Ads SDK के विज्ञापन दिखाने तक 0
ऊंचाई दिखती है.
कस्टम सर्च विज्ञापन हटा दिए गए हैं
इन क्लास को हटा दिया गया है और इनकी जगह कोई दूसरी क्लास नहीं जोड़ी गई है:
GADDynamicHeightSearchBannerView
GADDynamicHeightSearchRequest
GADSearchBannerView
गड़बड़ी कोड में बदलाव
इन गड़बड़ी कोड में बदलाव किया गया है:
कक्षा | नोट |
---|---|
GADErrorMediationNoFill |
अब गड़बड़ियां GADErrorNoFill के तौर पर दिखेंगी. |
GADErrorReceivedInvalidResponse |
इसे GADErrorReceivedInvalidAdString से बदल दिया गया है. |
GADSimulatorID हटाया गया
GADSimulatorID
को हटा दिया गया है. सिम्युलेटर, डिफ़ॉल्ट रूप से पहले से ही टेस्ट मोड में होते हैं.
कस्टम टारगेटिंग में बदलाव
GADRequest
पर मौजूद customTargeting
डिक्शनरी में, अब वैल्यू टाइप के तौर पर String
के बजाय Any
का इस्तेमाल किया जाता है. इससे एपीआई को संख्या वाली वैल्यू पास की जा सकती हैं.
अतिरिक्त पैरामीटर में बदलाव
max_ad_content_rating
कुंजी कोadditionalParameters
में पास करने की सुविधा अब काम नहीं करती. विज्ञापन के लिए सबसे ज़्यादा रेटिंग सेट करने के लिए, विज्ञापन कॉन्टेंट फ़िल्टर करने की सुविधा देखें.
v10 से v11 पर माइग्रेट करना
कम से कम डिप्लॉयमेंट टारगेट
डिप्लॉयमेंट के कम से कम टारगेट को iOS 12 पर सेट किया गया है.
Xcode का कम से कम वर्शन
Xcode के कम से कम इस्तेमाल किए जा सकने वाले वर्शन को 15.1 कर दिया गया है.
iOS 12 पर विज्ञापन दिखना बंद हो जाते हैं
Google Mobile Ads SDK का 11.0.0 वर्शन, सिर्फ़ iOS 13 और इसके बाद के वर्शन पर चलने वाले डिवाइसों पर विज्ञापन दिखाता है.
GoogleAppMeasurement की डिपेंडेंसी हटाई गई
वर्शन 11.0.0 में, GoogleAppMeasurement
पर निर्भरता हटा दी गई है. AdMob में उपयोगकर्ता मेट्रिक टॉगल की सुविधा देने वाली यह डिपेंडेंसी, 2024 की शुरुआत में बंद कर दी जाएगी. AdMob में उपयोगकर्ता मेट्रिक का डेटा देखना जारी रखने के लिए, अपने AdMob ऐप्लिकेशन को Firebase से लिंक करें और अपने ऐप्लिकेशन में Firebase के लिए Google Analytics SDK टूल इंटिग्रेट करें.
फ़ुल-स्क्रीन विज्ञापन दिखाने के तरीके में बदलाव
यहां दिए गए बदलाव, अलग-अलग विज्ञापन फ़ॉर्मैट पर असर डालते हैं:
- ऐप्लिकेशन खोलने पर दिखने वाला विज्ञापन
- मध्यवर्ती
- इनाम दिया गया
- इनाम वाला इंटरस्टीशियल विज्ञापन
-canPresentFromRootViewController:error:
और -presentFromRootViewController:
में व्यू कंट्रोलर पैरामीटर, नल हो सकता है. अगर शून्य पास किया जाता है, तो विज्ञापन को व्यू कंट्रोलर के क्रम में सबसे ऊपर मौजूद व्यू कंट्रोलर से दिखाया जाता है.
हटाए गए तरीके
इन तरीकों को हटा दिया गया है.
v11.0.0 टाइप | तरीका | नोट |
---|---|---|
GADAppOpenAd | load(withAdUnitID adUnitID: String, request: GADRequest?, orientation: UIInterfaceOrientation) |
इसके बजाय, load(withAdUnitID adUnitID: String, request: GADRequest?) का इस्तेमाल करें. |
GADMediationBannerAdEventDelegate | willBackgroundApplication() |
कोई विकल्प नहीं है. |
GADMediationInterstitialAdEventDelegate | willBackgroundApplication() |
कोई विकल्प नहीं है. |
GADMediationNativeAdEventDelegate | willBackgroundApplication() |
कोई विकल्प नहीं है. |
GADMediationRewardedAdEventDelegate | didRewardUser(with reward: GADAdReward) |
इसके बजाय, didRewardUser() का इस्तेमाल करें. |
GADMediatedUnifiedNativeAdNotificationSource | mediatedNativeAdWillLeaveApplication(_ mediatedNativeAd: GADMediatedUnifiedNativeAd) |
कोई विकल्प नहीं है. |
GADRequestConfiguration | setSameAppKeyEnabled(_ enabled: Bool) |
इसके बजाय, setPublisherFirstPartyIDEnabled(_ enabled: Bool) का इस्तेमाल करें. |
tagForUnderAge(ofConsent underAgeOfConsent: Bool) |
इसके बजाय, tagForUnderAgeOfConsent प्रॉपर्टी का इस्तेमाल करें. |
|
tag(forChildDirectedTreatment childDirectedTreatment: Bool) |
इसके बजाय, tagForChildDirectedTreatment प्रॉपर्टी का इस्तेमाल करें. |
हटाए गए प्रॉपर्टी
इन प्रॉपर्टी को हटा दिया गया है.
v11.0.0 क्लास | प्रॉपर्टी | नोट |
---|---|---|
GADMediationAdConfiguration | hasUserLocation | कोई विकल्प नहीं है. |
userLatitude | ||
userLongitude | ||
userLocationAccuracyInMeters | ||
childDirectedTreatment | इसके बजाय, GADMobileAds.sharedInstance.requestConfiguration.tagForChildDirectedTreatment का इस्तेमाल करें. |
|
GADResponseInfo | adNetworkClassName | इसके बजाय, loadedAdNetworkResponseInfo से adNetworkClassName का इस्तेमाल करें. |
GADAdFormatUnknown हटाया गया
GADAdFormatUnknown
को हटाया गया है और उसकी जगह कोई दूसरा आइटम नहीं जोड़ा गया है.
SDK टूल के वर्शन को लॉग करने के तरीके में बदलाव
वर्शन 11.0.0 में sdkVersion
को हटा दिया गया है. Google Mobile Ads SDK के वर्शन को लॉग करने के लिए,
versionNumber
का इस्तेमाल करें.
वर्शन 10.0.0
GADMobileAds.sharedInstance().sdkVersion
वर्शन 11.0.0
GADGetStringFromVersionNumber(GADMobileAds.sharedInstance().versionNumber)
GADAdLoader में गड़बड़ी की जानकारी देने की सुविधा में बदलाव
वर्शन 11.0.0 से, GADAdLoader
विज्ञापन अनुरोध नहीं करता है. ऐसा तब होता है, जब इसका delegate
, अनुरोध किए गए विज्ञापन टाइप के डेलिगेट प्रोटोकॉल के मुताबिक नहीं होता. इससे पहले, विज्ञापन के लिए अनुरोध करने के बाद यह फ़ेल हो गया था.
जांच के तरीके में बदलाव
नीचे दी गई टेबल में, true
वैल्यू के लिए अपडेट की गई शर्तें दी गई हैं.
कक्षा | प्रॉपर्टी |
---|---|
GADMediationAdConfiguration | isTestRequest |
GADCustomEventRequest | isTesting |
v10.0.0 | v11.0.0 |
|
|
v9 से v10 पर माइग्रेट करना
iOS 11 पर विज्ञापन दिखना बंद हो जाते हैं
Google Mobile Ads SDK का 10.0.0 वर्शन, सिर्फ़ iOS 12 और इसके बाद के वर्शन पर चलने वाले डिवाइसों पर विज्ञापन दिखाता है.
Google Mobile Ads SDK के 10.0.0 वर्शन पर अपग्रेड करने से, iOS 11 और iOS 10 वाले डिवाइसों पर आपका ऐप्लिकेशन काम करना बंद नहीं करेगा. हालांकि, इन डिवाइसों पर कोई विज्ञापन नहीं दिखाया जाएगा.
बिटकोड के साथ ऐप्लिकेशन बनाने की सुविधा अब काम नहीं करती
Google Mobile Ads SDK को इंटिग्रेट करने के लिए, अब आपको अपने मोबाइल ऐप्लिकेशन में बिटकोड बंद करना होगा.
हटाए गए टाइप
टाइप | नोट |
---|---|
GADGender | कोई विकल्प नहीं है. |
GADMRewardBasedVideoAdNetworkAdapterProtocol | नेटवर्क चुनें पर लिस्ट किए गए सभी इनाम वाले मीडिएशन अडैप्टर, एक साल से ज़्यादा समय से इन प्रोटोकॉल का इस्तेमाल नहीं कर रहे हैं. मीडिएशन और कस्टम इवेंट के लिए, GADMediationAdapter का इस्तेमाल करें. |
GADMRewardBasedVideoAdNetworkConnectorProtocol |
हटाए गए प्रॉपर्टी
इन प्रॉपर्टी को हटा दिया गया है और इनकी जगह कोई दूसरी प्रॉपर्टी नहीं जोड़ी गई है.
v10.0.0 क्लास | प्रॉपर्टी |
---|---|
GADMediationAdRequest | userBirthday |
userGender | |
userHasLocation | |
userLatitude | |
userLongitude | |
userLocationAccuracyInMeters | |
userLocationDescription | |
GADCustomEventRequest | userHasLocation |
userLatitude | |
userLongitude | |
userLocationAccuracyInMeters | |
userLocationDescription |
v8 से v9 पर माइग्रेट करना
iOS 10 पर विज्ञापन दिखना बंद हो जाते हैं
Google Mobile Ads SDK 9.0.0 वर्शन, iOS 11 या इसके बाद के वर्शन पर काम करता है.
Google Mobile Ads SDK के 9.0.0 वर्शन पर अपग्रेड करने से, iOS 10 वाले डिवाइसों पर आपका ऐप्लिकेशन काम करना बंद नहीं करेगा. हालांकि, उन डिवाइसों पर कोई विज्ञापन नहीं दिखाया जाएगा.
स्टेटस बार कंट्रोल को ज़्यादा सख्ती से लागू करना
वर्शन 9.0.0 से, फ़ुल-स्क्रीन फ़ॉर्मैट वाले विज्ञापन दिखाते समय, आपके ऐप्लिकेशन को यह पक्का करना होगा कि विज्ञापन, स्टेटस बार के प्रज़ेंटेशन को कंट्रोल कर सकें. ऐसा न करने पर, आपको लॉग में गड़बड़ी का मैसेज दिखेगा.
आपके ऐप्लिकेशन में व्यू कंट्रोलर के लेआउट के आधार पर, हो सकता है कि आपको यह पक्का करने के लिए कोई बदलाव न करना पड़े. देखें कि आपको अपने विज्ञापन के rootViewController
पर childViewControllerForStatusBarHidden
प्रॉपर्टी सेट करनी है या नहीं.
adDidPresentFullScreenContent: का नाम बदलकर adWillPresentFullScreenContent: करें
इसमें कोई बदलाव नहीं किया गया है. डेलिगेट तरीके को विज्ञापन दिखाए जाने से ठीक पहले लागू किया जाता है. इसलिए, नए तरीके का नाम इसकी फ़ंक्शनैलिटी को बेहतर तरीके से दिखाता है.
GADRequest पर जगह की जानकारी की सेटिंग वाला एपीआई हटाएं
- (void)setLocationWithLatitude:longitude:accuracy:
को GADRequest
से मिटा दिया गया है, क्योंकि Google, विज्ञापन टारगेट करने के लिए जगह की जानकारी के डेटा का इस्तेमाल नहीं करता. ज़रूरत पड़ने पर, तीसरे पक्ष के विज्ञापन नेटवर्क को जानकारी देने के लिए, तीसरे पक्ष के एपीआई का इस्तेमाल करें.
कस्टम इवेंट इंटरफ़ेस बंद होना
कस्टम इवेंट की मदद से, AdMob मीडिएशन का इस्तेमाल करने वाले पब्लिशर, ऐसे विज्ञापन नेटवर्क के लिए वॉटरफ़ॉल मीडिएशन जोड़ सकते हैं जो AdMob पर काम नहीं करता.
सभी कस्टम इवेंट प्रोटोकॉल बंद कर दिए गए हैं. इसके बजाय, एक जैसी सुविधाएं पाने के लिए, मौजूदा GADMediationAdapter
और GADMediationAdEventDelegate
प्रोटोकॉल का इस्तेमाल करें. इस बदलाव से, आपको इनाम वाले विज्ञापनों और इंटरस्क्रॉलर विज्ञापनों के लिए कस्टम इवेंट बनाने की सुविधा मिलती है. पहले यह सुविधा उपलब्ध नहीं थी. साथ ही, इससे आपको बेहतर तरीके से जानकारी मिलती है.
API
नीचे दी गई टेबल में, कस्टम इवेंट एपीआई से जुड़े मीडिएशन अडैप्टर एपीआई दिए गए हैं. इनका इस्तेमाल वर्शन 9.0.0 से शुरू किया जाना चाहिए.
v8 | v9 | |
---|---|---|
GADCustomEventBanner GADCustomEventInterstitial GADCustomEventNativeAd |
GADMediationAdapter | GADMediationBannerAd GADMediationInterstitialAd GADMediationInterscrollerAd GADMediationRewardedAd GADMediationNativeAd |
delegate
|
Delegate, GADMediationAdapter क्लास के हर लोड फ़ंक्शन के लोड पूरा होने पर हैंडलर से मिलता है
|
|
-init |
-init |
|
-requestBannerAd:parameter: |
-loadBannerForAdConfiguration: |
|
-requestInterstitialAdWith |
-loadInterstitialFor |
|
-requestNativeAdWithParameter:
|
-loadNativeAdFor |
|
लागू नहीं | -loadInterscrollerAdFor |
|
लागू नहीं | -loadRewardedAdFor |
|
-presentFromRootViewController:
|
-presentFromViewController: |
|
-handlesUserClicks |
-handlesUserClicks |
|
-handlesUserImpressions |
-handlesUserImpressions |
डेलिगेट करने के तरीके
नीचे दी गई टेबल में, कस्टम इवेंट डेलिगेट के उन तरीकों के बारे में बताया गया है जिनका इस्तेमाल वर्शन 9.0.0 से किया जाना चाहिए. साथ ही, इसमें मीडिएशन विज्ञापन इवेंट डेलिगेट के तरीकों के बारे में भी बताया गया है.
v8 | v9 | |
---|---|---|
GADCustomEventBannerDelegate GADCustomEventInterstitialDelegate GADCustomEventNativeAdDelegate |
GADMediationAdEventDelegate | GADMediationAd |
-customEventBanner:didReceiveAd: -customEventInterstitialDidReceiveAd:
|
विज्ञापन लोड होने का स्टेटस, GADMediationAdapter क्लास में मौजूद हर लोड फ़ंक्शन के लोड पूरा होने वाले हैंडलर में शामिल होता है
|
|
-customEventBanner:didFailAd: -customEventInterstitial:didFailAd:
|
||
-customEventBannerWasClicked: -customEventInterstitialWasClicked:
|
-reportClick |
|
-customEventBannerWill -customEventInterstitialWill
|
-willPresentFullScreenView |
|
-customEventBannerWill -customEventInterstitialWill
|
-willDismissFullScreenView |
|
-customEventBannerDid -customEventInterstitialDid
|
-didDismissFullScreenView |
|
-customEventBannerWill -customEventInterstitialWill
|
-willBackgroundApplication |
|
viewControllerFor |
-[GADMediationBannerAd view] |
हटाए गए/बदले गए अन्य तरीके और कॉन्स्टेंट
तरीके, कॉन्स्टेंट या प्रॉपर्टी में बदलाव | |
---|---|
kGAD- प्रीफ़िक्स वाले कॉन्सटेंट
|
हटाया गया. GAD- प्रीफ़िक्स वाले कॉन्स्टेंट का इस्तेमाल करें.
|
GADAdNetworkResponseInfo
|
credentials को हटा दिया गया है. इसके बजाय, adUnitMapping
का इस्तेमाल करें.
|
GADCustomNativeAd
|
GADCustomNativeAd में mediaView का अब इस्तेमाल नहीं किया जा सकता.
इसके बजाय, mediaContent का इस्तेमाल करें.
|
GoogleMobileAds में ऐप्लिकेशन में खरीदारी करने से जुड़े एपीआई |
inAppPurchase में GoogleMobileAds एपीआई हटा दिए गए थे.
|
v7 से v8 पर माइग्रेट करना
Google Mobile Ads SDK के वर्शन 8.0.0 में कुछ बड़े बदलाव किए गए हैं. साथ ही, कुछ एपीआई के नाम बदले गए हैं और कुछ हटाए भी गए हैं.
फ़ुल-स्क्रीन फ़ॉर्मैट वाले एपीआई के अपडेट
वर्शन 8.0.0 से, इंटरस्टीशियल और इनाम वाले विज्ञापनों के लिए, सामान्य फ़ुल स्क्रीन विज्ञापन स्टाइल का इस्तेमाल किया जाता है, ताकि विज्ञापनों में एक जैसा अनुभव मिले. फ़ुल स्क्रीन वाले इन नए विज्ञापन एपीआई और वर्शन 7 के फ़ुल स्क्रीन वाले विज्ञापन एपीआई में दो मुख्य अंतर हैं:
स्टैटिक क्लास मेथड
load
.फ़ुल-स्क्रीन विज्ञापन को लोड/दिखाने का पिछला तरीका यह है:
- विज्ञापन ऑब्जेक्ट इंस्टेंस बनाएं और उसका रेफ़रंस सेव करें.
- लोड और शो कॉलबैक को मैनेज करने के लिए, किसी डेलिगेट को असाइन करें.
- विज्ञापन लोड करें.
- देखें कि विज्ञापन,
isReady
का इस्तेमाल करके लोड किया गया है या नहीं. - विज्ञापन दिखाएं.
वर्शन 8 में, इस तरीके में थोड़ा बदलाव किया गया है. लोड कॉलबैक अब डेलिगेट का हिस्सा नहीं हैं. इसके बजाय, इन्हें
load
तरीके में, कंप्लीशन हैंडलर के तौर पर पास किया जाता है:- विज्ञापन क्लास पर स्टैटिक लोड मेथड को कॉल करें और लोड पूरा होने का हैंडलर दें.
- लोड होने की प्रोसेस पूरी होने पर, कॉलबैक में लोड किए गए विज्ञापन का रेफ़रंस सेव करें.
- ऐसा डेलिगेट असाइन करें जो शो कॉलबैक को मैनेज करता हो.
- विज्ञापन दिखाएं.
नए तरीके से ये फ़ायदे मिलते हैं:
- आपको कभी भी ऐसा विज्ञापन नहीं दिखेगा जो लोड नहीं हुआ है.
- विज्ञापन ऑब्जेक्ट लोड होने के दौरान, आपको उसे होल्ड करने की ज़रूरत नहीं है.
विज्ञापन के इवेंट एक जैसे होने चाहिए.
इवेंट किस तरह का है मौजूदा एपीआई v8 API इवेंट लोड करना GADInterstitialDelegate
याGADRewardedAdDelegate
GADInterstitialAdLoadCompletionHandler
याGADRewardedAdLoadCompletionHandler
प्रज़ेंटेशन इवेंट GADFullScreenContentDelegate
पहले, किसी भी विज्ञापन इवेंट को सुनने के लिए, आपको एक ऐसी क्लास रजिस्टर करनी होती थी जो इंटरस्टीशियल विज्ञापन की डेलिगेट प्रॉपर्टी के लिए
GADInterstitialDelegate
प्रोटोकॉल लागू करती है. इसके अलावा, आपको एक ऐसी क्लास रजिस्टर करनी होती थी जो इनाम वाले विज्ञापन की डेलिगेट प्रॉपर्टी के लिएGADRewardedAdDelegate
प्रोटोकॉल लागू करती है. यह इस बात पर निर्भर करता है कि आपने किस फ़ॉर्मैट का इस्तेमाल किया है. इस डेलिगेट में, विज्ञापन को लोड करने और उसे दिखाने के लाइफ़साइकल, दोनों से जुड़े तरीके मौजूद थे.वर्शन 8 में, लोड और प्रज़ेंटेशन इवेंट अलग-अलग होते हैं. अब विज्ञापन दिखाने से पहले,
GADFullScreenContentDelegate
को कभी भी रजिस्टर किया जा सकता है. इसके लिए, विज्ञापन लोड करने से पहले एक ही डेलिगेट सेट करने की ज़रूरत नहीं है. विज्ञापन लोड करने से जुड़े इवेंट, जो हर फ़ॉर्मैट के लिए खास होते हैं, लोड करने के तरीके में पास किए गए लोड पूरा होने के एक हैंडलर पर चले जाते हैं.
मध्यवर्ती
विज्ञापन लोड करें
नीचे दिए गए कोड स्निपेट में, पेज पर अचानक दिखने वाले विज्ञापन को लोड करने का तरीका बताया गया है. साथ ही, यह भी बताया गया है कि विज्ञापन लोड होने या लोड न होने पर इवेंट कैसे सुने जाते हैं.
v7
Swift
import GoogleMobileAds import UIKit class ViewController: UIViewController, GADInterstitialDelegate { var interstitial: GADInterstitial! override func viewDidLoad() { super.viewDidLoad() interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910") interstitial.delegate = self let request = GADRequest() interstitial.load(request) } /// Tells the delegate an ad request succeeded. func interstitialDidReceiveAd(_ ad: GADInterstitial) { print("Interstitial ad loaded.") } /// Tells the delegate an ad request failed. func interstitial(_ ad: GADInterstitial, didFailToReceiveAdWithError error: GADRequestError) { print("Interstitial ad failed to load with error: \(error.localizedDescription)") } }
Objective-C
@import GoogleMobileAds; @import UIKit; @interface ViewController ()@property(nonatomic, strong) GADInterstitial *interstitial; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.interstitial = [[GADInterstitial alloc] initWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910"]; self.interstitial.delegate = self; GADRequest *request = [GADRequest request]; [self.interstitial loadRequest:request]; } /// Tells the delegate an ad request succeeded. - (void)interstitialDidReceiveAd:(GADInterstitial *)ad { NSLog(@"Insterstitial ad loaded."); } /// Tells the delegate an ad request failed. - (void)interstitial:(GADInterstitial *)ad didFailToReceiveAdWithError:(GADRequestError *)error { NSLog(@"Interstitial ad failed to load with error: %@", [error localizedDescription]); }
v8
Swift
import GoogleMobileAds import UIKit class ViewController: UIViewController, GADFullScreenContentDelegate { var interstitial: GADInterstitialAd? override func viewDidLoad() { super.viewDidLoad() let request = GADRequest() GADInterstitialAd.load(withAdUnitID:"ca-app-pub-8123415297019784/4985798738", request: request, completionHandler: { (ad, error) in if let error = error { print("Failed to load interstitial ad with error: \(error.localizedDescription)") return } self.interstitial = ad self.interstitial.fullScreenContentDelegate = self } ) } }
Objective-C
@import GoogleMobileAds; @import UIKit; @interface ViewController ()@property(nonatomic, strong) GADInterstitialAd *interstitial; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; GADRequest *request = [GADRequest request]; [GADInterstitialAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910" request:request completionHandler:^(GADInterstitialAd *ad, NSError *error) { if (error) { NSLog(@"Failed to load interstitial ad with error: %@", [error localizedDescription]); return; } self.interstitial = ad; self.interstitial.fullScreenContentDelegate = self; }]; }
Display Network में दिखने वाला विज्ञापन
v7
Swift
func showInterstitial() { ... if interstitial.isReady { interstitial.present(fromRootViewController: self) } else { print("Ad wasn't ready") } }
Objective-C
- (void)showInterstitial: { ... if (self.interstitial.isReady) { [self.interstitial presentFromRootViewController:self]; } else { NSLog(@"Ad wasn't ready"); } }
v8
Swift
func showInterstitial() { ... if let ad = interstitial { ad.present(fromRootViewController: self) } else { print("Ad wasn't ready") } }
Objective-C
- (void)showInterstitial: { ... if (self.interstitial) { [self.interstitial presentFromRootViewController:self]; } else { NSLog(@"Ad wasn't ready"); } }
प्रज़ेंटेशन विज्ञापन के इवेंट
नीचे दिए गए कोड स्निपेट से पता चलता है कि विज्ञापन के दिखने (सफलतापूर्वक या नहीं) और खारिज होने पर, कॉलबैक को कैसे हैंडल किया जाता है.
v7
Swift
override func viewDidLoad() { super.viewDidLoad() interstitial = GADInterstitial(adUnitID: "ca-app-pub-3940256099942544/4411468910") interstitial.delegate = self ... } /// Tells the delegate that an interstitial will be presented. func interstitialWillPresentScreen(_ ad: GADInterstitial) { print("Interstitial ad will be presented.") } /// Tells the delegate the interstitial is to be animated off the screen. func interstitialWillDismissScreen(_ ad: GADInterstitial) { print("Interstitial ad will be dismissed.") } /// Tells the delegate the interstitial had been animated off the screen. func interstitialDidDismissScreen(_ ad: GADInterstitial) { print("Interstitial ad dismissed.") } /// Tells the delegate that a user click will open another app /// (such as the App Store), backgrounding the current app. /// /// This is not a reliable callback for an ad click event and is removed in /// version 8. If you wish to listen to an ad causing a user to leave the app, /// use applicationWillResignActive: or sceneWillResignActive: instead. func interstitialWillLeaveApplication(_ ad: GADInterstitial) { print("Interstitial ad will leave application.") }
Objective-C
- (void)viewDidLoad { [super viewDidLoad]; self.interstitial = [[GADInterstitial alloc] initWithAdUnitID:"ca-app-pub-3940256099942544/4411468910"]; self.interstitial.delegate = self; ... } /// Tells the delegate that an interstitial will be presented. - (void)interstitialWillPresentScreen:(GADInterstitial *)ad { NSLog(@"Interstitial ad will be presented."); } /// Tells the delegate the interstitial is to be animated off the screen. - (void)interstitialWillDismissScreen:(GADInterstitial *)ad { NSLog(@"Interstitial ad will be dismissed."); } /// Tells the delegate the interstitial had been animated off the screen. - (void)interstitialDidDismissScreen:(GADInterstitial *)ad { NSLog(@"Interstitial ad dismissed."); } /// Tells the delegate that a user click will open another app /// (such as the App Store), backgrounding the current app. /// /// This is not a reliable callback for an ad click event and is removed in /// version 8. If you wish to listen to an ad causing a user to leave the app, /// use applicationWillResignActive: or sceneWillResignActive: instead. - (void)interstitialWillLeaveApplication:(GADInterstitial *)ad { NSLog(@"Interstitial ad will leave application."); }
v8
Swift
override func viewDidLoad() { super.viewDidLoad() let request = GADRequest() GADInterstitialAd.load(withAdUnitID:"ca-app-pub-8123415297019784/4985798738", request: request, completionHandler: { (ad, error) in if let error = error { print(error.localizedDescription) return } self.interstitial = ad self.interstitial.fullScreenContentDelegate = self } ) } func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) { print("Ad did present full screen content.") } func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) { print("Ad failed to present full screen content with error \(error.localizedDescription).") } func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) { print("Ad did dismiss full screen content.") }
Objective-C
- (void)viewDidLoad { [super viewDidLoad]; GADRequest *request = [GADRequest request]; [GADInterstitialAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/4411468910" request:request completionHandler:^(GADInterstitialAd *ad, NSError *error) { if (error) { NSLog(@"interstitial:didFailToReceiveAdWithError: %@", [error localizedDescription]) return; } self.interstitial = ad; self.interstitial.fullScreenContentDelegate = self; }]; } - (void)adDidPresentFullScreenContent:(id)ad { NSLog(@"Ad did present full screen content."); } - (void)ad:(id )ad didFailToPresentFullScreenContentWithError:(NSError *)error { NSLog(@"Ad failed to present full screen content with error %@.", [error localizedDescription]); } - (void)adDidDismissFullScreenContent:(id )ad { NSLog(@"Ad did dismiss full screen content."); }
इनाम दिया गया
विज्ञापन लोड करें
v7
Swift
import GoogleMobileAds import UIKit class ViewController: UIViewController, GADRewardedAdDelegate { /// The rewarded ad. var rewardedAd: GADRewardedAd? override func viewDidLoad() { super.viewDidLoad() rewardedAd = GADRewardedAd(adUnitID: "ca-app-pub-3940256099942544/1712485313") rewardedAd.delegate = self rewardedAd?.load(GADRequest()) { error in if let error = error { print("Rewarded ad failed to load with error: \(error.localizedDescription)") } else { print("Rewarded ad loaded.") } } } }
Objective-C
@import GoogleMobileAds; @import UIKit; @interface ViewController ()@property(nonatomic, strong) GADRewardedAd *rewardedAd; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.rewardedAd = [[GADRewardedAd alloc] initWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313"]; self.rewardedAd.delegate = self; GADRequest *request = [GADRequest request]; [self.rewardedAd loadRequest:request completionHandler:^(GADRequestError * _Nullable error) { if (error) { NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]); } else { NSLog(@"Rewarded ad loaded."); } }]; }
v8
Swift
import GoogleMobileAds import UIKit class ViewController: UIViewController, GADFullScreenContentDelegate { /// The rewarded ad. var rewardedAd: GADRewardedAd? override func viewDidLoad() { super.viewDidLoad() let request = GADRequest() GADRewardedAd.load(withAdUnitID: "ca-app-pub-8123415297019784/9501821136", request: request, completionHandler: { (ad, error) in if let error = error { print("Rewarded ad failed to load with error: \(error.localizedDescription)") return } self.rewardedAd = ad self.rewardedAd?.fullScreenContentDelegate = self } ) } }
Objective-C
@import GoogleMobileAds; @import UIKit; @interface ViewController ()@property(nonatomic, strong) GADRewardedAd *rewardedAd; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; GADRequest *request = [GADRequest request]; [GADRewardedAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313" request:request completionHandler:^(GADRewardedAd *ad, NSError *error) { if (error) { NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]); return; } self.rewardedAd = ad; NSLog(@"Rewarded ad loaded."); self.rewardedAd.fullScreenContentDelegate = self; }
डिसप्ले विज्ञापन दिखाना और इनाम मैनेज करना
इनाम वाले विज्ञापनों में, आपको उस इवेंट को मैनेज करना होता है जब कोई उपयोगकर्ता इनाम पाता है. GADRewardedAd
एपीआई के सातवें वर्शन में, GADRewardedAdDelegate
प्रोटोकॉल के हिस्से के तौर पर rewardedAd:userDidEarnReward:
को लागू किया जाता है.
वर्शन 8 के लिए, विज्ञापन दिखाने के लिए GADUserDidEarnRewardHandler
लागू करें.
v7
Swift
func showRewardedAd() { ... if rewardedAd.isReady { rewardedAd.present(fromRootViewController: self delegate:self) } else { print("Ad wasn't ready") } } /// Tells the delegate that the user earned a reward. func rewardedAd(_ rewardedAd: GADRewardedAd, userDidEarnReward: GADAdReward) { // TODO: Reward the user. }
Objective-C
- (void)showRewardedAd: { ... if (self.rewardedAd.isReady) { [self.rewardedAd presentFromRootViewController:self delegate:self]; } else { NSLog(@"Ad wasn't ready"); } } /// Tells the delegate that the user earned a reward. - (void)rewardedAd:(GADRewardedAd *)rewardedAd userDidEarnReward:(GADAdReward *)reward { // TODO: Reward the user. }
v8
Swift
func showRewardedAd() { ... if let ad = rewardedAd { ad.present(fromRootViewController: self, userDidEarnRewardHandler: { let reward = ad.adReward // TODO: Reward the user. } ) } else { print("Ad wasn't ready") } }
Objective-C
- (void)showRewardedAd: { ... if (self.rewardedAd) { [self.rewardedAd presentFromRootViewController:self userDidEarnRewardHandler:^ { GADAdReward *reward = self.rewardedAd.adReward; // TODO: Reward the user. }]; } else { NSLog(@"Ad wasn't ready"); } }
प्रज़ेंटेशन विज्ञापन के इवेंट
GADRewardedAd
एपीआई की मदद से, विज्ञापन दिखाने वाले तरीके को GADRewardedAdDelegate
पास किया जाता है. GADRewardedAd
API की मदद से, विज्ञापन दिखाने से पहले विज्ञापन पर GADFullscreenContentDelegate
को प्रॉपर्टी के तौर पर सेट किया जाता है.
v7
Swift
func showRewardedAd() { ... if rewardedAd.isReady { rewardedAd.present(fromRootViewController: self delegate:self) } else { print("Ad wasn't ready") } } /// Tells the delegate that the rewarded ad was presented. func rewardedAdDidPresent(_ rewardedAd: GADRewardedAd) { print("Rewarded ad presented.") } /// Tells the delegate that the rewarded ad was dismissed. func rewardedAdDidDismiss(_ rewardedAd: GADRewardedAd) { print("Rewarded ad dismissed.") } /// Tells the delegate that the rewarded ad failed to present. func rewardedAd(_ rewardedAd: GADRewardedAd, didFailToPresentWithError error: Error) { print("Rewarded ad failed to present with error: \(error.localizedDescription).") }
Objective-C
- (void)showRewardedAd: { ... if (self.rewardedAd.isReady) { [self.rewardedAd presentFromRootViewController:self delegate:self]; } else { NSLog(@"Ad wasn't ready"); } } /// Tells the delegate that the rewarded ad was presented. - (void)rewardedAdDidPresent:(GADRewardedAd *)rewardedAd { NSLog(@"Rewarded ad presented."); } /// Tells the delegate that the rewarded ad failed to present. - (void)rewardedAd:(GADRewardedAd *)rewardedAd didFailToPresentWithError:(NSError *)error { NSLog(@"Rewarded ad failed to present with error: %@", [error localizedDescription]); } /// Tells the delegate that the rewarded ad was dismissed. - (void)rewardedAdDidDismiss:(GADRewardedAd *)rewardedAd { NSLog(@"Rewarded ad dismissed."); }
v8
Swift
override func viewDidLoad() { super.viewDidLoad() let request = GADRequest() GADRewardedAd.load(withAdUnitID: "ca-app-pub-8123415297019784/9501821136", request: request, completionHandler: { (ad, error) in if let error = error { print(error.localizedDescription) return } self.rewardedAd = ad self.rewardedAd?.fullScreenContentDelegate = self } ) } /// Tells the delegate that the rewarded ad was presented. func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) { print("Rewarded ad presented.") } /// Tells the delegate that the rewarded ad was dismissed. func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) { print("Rewarded ad dismissed.") } /// Tells the delegate that the rewarded ad failed to present. func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) { print("Rewarded ad failed to present with error: \(error.localizedDescription).") }
Objective-C
- (void)viewDidLoad { [super viewDidLoad]; GADRequest *request = [GADRequest request]; [GADRewardedAd loadWithAdUnitID:@"ca-app-pub-3940256099942544/1712485313" request:request completionHandler:^(GADRewardedAd *ad, NSError *error) { if (error) { NSLog(@"Rewarded ad failed to load with error: %@", [error localizedDescription]); return; } self.rewardedAd = ad; NSLog(@"Rewarded ad loaded."); self.rewardedAd.fullScreenContentDelegate = self; } /// Tells the delegate that the rewarded ad was presented. - (void)adDidPresentFullScreenContent:(id)ad { NSLog(@"Rewarded ad presented."); } /// Tells the delegate that the rewarded ad failed to present. - (void)ad:(id )ad didFailToPresentFullScreenContentWithError:(NSError *)error { NSLog(@"Rewarded ad failed to present with error: %@", [error localizedDescription]); } /// Tells the delegate that the rewarded ad was dismissed. - (void)adDidDismissFullScreenContent:(id )ad { NSLog(@"Rewarded ad dismissed."); }
GADRewardedBasedVideoAd के लेगसी एपीआई को हटाना
नए GADRewardedAd
एपीआई को पहली बार मार्च 2019 में लॉन्च किया गया था. साथ ही, यह 18 महीनों से ज़्यादा समय से, इनाम वाले वीडियो के लिए सबसे ज़्यादा इस्तेमाल किया जाने वाला एपीआई है. इसमें लेगसी GADRewardedBasedVideoAd
एपीआई की तुलना में ज़्यादा सुविधाएं हैं. जैसे, एक बार में एक से ज़्यादा इनाम वाले विज्ञापन लोड करने की सुविधा.
SDK टूल के वर्शन 8.0.0 में, लेगसी GADRewardedBasedVideoAd
एपीआई को हटा दिया गया है.
स्मार्ट बैनर को बंद करके अडैप्टिव बैनर का इस्तेमाल करना
स्मार्ट बैनर विज्ञापनों के बजाय, अब अडैप्टिव बैनर विज्ञापनों का इस्तेमाल किया जाता है. अडैप्टिव बैनर, बेहतर परफ़ॉर्मेंस देते हैं. साथ ही, विज्ञापन की चौड़ाई सेट करने में ज़्यादा सुविधा देते हैं. अगर आपको फ़ुल-विड्थ बैनर का इस्तेमाल जारी रखना है, तो अडैप्टिव बैनर का इस्तेमाल करके ऐसा किया जा सकता है. इसके लिए, यहां दिया गया कोड स्निपेट देखें:
Swift
class ViewController: UIViewController { override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) // Note: The safe area is not known until viewWillAppear. let adSize = getFullWidthAdaptiveAdSize() } func getFullWidthAdaptiveAdSize() -> GADAdSize { // Here safe area is taken into account, hence the view frame is used after the // view has been laid out. let frame = { () -> CGRect in if #available(iOS 11.0, *) { return view.frame.inset(by: view.safeAreaInsets) } else { return view.frame } }() return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(frame.size.width) } }
Objective-C
@implementation ViewController - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; // Note: The safe area is not known until viewWillAppear. GADAdSize adSize = [self getFullWidthAdaptiveAdSize]; } - (GADAdSize)getFullWidthAdaptiveAdSize { CGRect frame = self.view.frame; // Here safe area is taken into account, hence the view frame is used after // the view has been laid out. if (@available(iOS 11.0, *)) { frame = UIEdgeInsetsInsetRect(self.view.frame, self.view.safeAreaInsets); } return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(frame.size.width); } @end
ऐप्लिकेशन के कॉलबैक को हटाने का अनुरोध
सभी विज्ञापन फ़ॉर्मैट के लिए willLeaveApplication
कॉलबैक को हटा दिया गया है. इसके बजाय, applicationDidEnterBackground:
और sceneDidEnterBackground:
तरीकों का इस्तेमाल किया जा सकता है. ओएस-लेवल के एपीआई का इस्तेमाल करके, आपको सूचना दी जाती है कि उपयोगकर्ता आपके ऐप्लिकेशन से कब बाहर निकले. इससे कोई फ़र्क़ नहीं पड़ता कि उपयोगकर्ता, विज्ञापन के साथ इंटरैक्ट करने की वजह से बाहर निकला है या किसी और वजह से.
ध्यान दें कि willLeaveApplication
कॉलबैक को कभी भी विज्ञापन क्लिक हैंडलर के तौर पर इस्तेमाल करने का मकसद नहीं था. साथ ही, क्लिक की रिपोर्ट करने के लिए इस कॉलबैक पर भरोसा करने से, सटीक मेट्रिक नहीं मिलती थी. उदाहरण के लिए, AdChoices आइकॉन पर क्लिक करने से बाहरी ब्राउज़र लॉन्च हुआ, जिसने कॉलबैक शुरू किया, लेकिन क्लिक को नहीं गिना.
क्लास का नाम बदलना
नीचे दी गई टेबल में, क्लास के उन नामों की सूची दी गई है जिन्हें वर्शन 8 में बदल दिया गया है या हटा दिया गया है. सारांश में:
GADUnifiedNativeAd
से जुड़ी सभी क्लास का नाम बदलकरGADNativeAd
कर दिया गया है.GADRewardBasedVideoAd
,GADNativeExpressAdView
, औरGADInstreamAd
को हटा दिया गया है.DFP
प्रीफ़िक्स वाली सभी क्लास कोGAM
प्रीफ़िक्स से बदल दिया गया है.
v7.68.0 क्लास | v8.0.0 क्लास |
---|---|
DFPBannerView | GAMBannerView |
DFPBannerViewOptions | GAMBannerViewOptions |
DFPInterstitial | GAMInterstitialAd |
DFPRequest | GAMRequest |
GADRequestError | NSError |
GADUnifiedNativeAdView | GADNativeAdView |
GADUnifiedNativeAd | GADNativeAd |
GADUnifiedNativeAdAssetIdentifiers | GADNativeAdAssetIdentifiers |
GADUnifiedNativeAdDelegate | GADNativeAdDelegate |
GADUnifiedNativeAdUnconfirmedClickDelegate | GADNativeAdUnconfirmedClickDelegate |
GADNativeCustomTemplateAd | GADCustomNativeAd |
GADNativeCustomTemplateAdLoaderDelegate | GADCustomNativeAdLoaderDelegate |
GADNativeAdDelegate | GADCustomNativeAdDelegate |
GADInAppPurchase | हटाया गया |
GADInterstitial | GADInterstitialAd |
GADNativeExpressAdView | हटाया गया |
GADRewardBasedVideoAd | हटाया गया |
GADInstreamAd | हटाया गया |
GADInstreamAdView | हटाया गया |
हटाए गए/बदले गए तरीके
यहां दी गई टेबल में, वर्शन 8 में हुए खास बदलावों के बारे में बताया गया है. सारांश में:
- पहले बंद किए गए तरीकों और प्रॉपर्टी को हटा दिया गया है.
-willLeaveApplication:
सभी फ़ॉर्मैट के लिए, डेलिगेट करने के तरीके हटा दिए गए हैं.- विज्ञापन नेटवर्क क्लास का नाम,
GADResponseInfo
प्रॉपर्टी में चला गया है. - टेस्ट डिवाइस आइडेंटिफ़ायर को
GADRequestConfiguration
प्रॉपर्टी में ले जाया गया है.
v7.68.0 क्लास | v7.68.0 API | v8.0.0 API | नोट |
---|---|---|---|
GADMobileAds | +configureWithApplicationID: | -startWithCompletionHandler: | ऐप्लिकेशन आईडी अब Info.plist में सेट हो गया है. |
+disableAutomatedInApp |
-disableAutomatedInApp |
||
+disableSDKCrashReporting | -disableSDKCrashReporting | ||
GADRequest | testDevices | GADRequestConfiguration |
testDeviceIdentifiers प्रॉपर्टी, सभी विज्ञापन अनुरोधों पर लागू होती है. वहीं, पुरानी testDevices प्रॉपर्टी को हर अनुरोध के हिसाब से सेट किया जाता था. |
लिंग | हटाया गया | ||
जन्मदिन | हटाया गया | ||
+sdkVersion | GADMobileAds.sharedInstance |
||
-setBirthday |
हटाया गया | ||
-setLocationWithDescription: | -setLocationWith |
||
-tagForChildDirectedTreatment: | [GADMobileAds.sharedInstance.requestConfiguration tagForChildDirectedTreatment] | ||
GADErrorCode | kGADError* | GADError* | सभी गड़बड़ी कोड कॉन्स्टेंट से k प्रीफ़िक्स हटा दिया गया है.
|
GADBannerView | hasAutoRefreshed | autoloadEnabled | |
inAppPurchaseDelegate | हटाया गया | ||
mediatedAdView | हटाया गया | ||
adNetworkClassName | responseInfo |
||
DFPBannerView | -setValidAdSizesWithSizes: | -setValidAdSizes: | |
DFPBannerViewOptions | -adSizeDelegate | हटाया गया | |
GADBannerViewDelegate | -adViewDidReceiveAd: | -bannerViewDidReceiveAd: | |
-adView:didFailToReceive |
-bannerView:didFailToReceive |
||
-adViewWillPresentScreen: | -bannerViewWillPresentScreen: | ||
-adViewWillDismissScreen: | -bannerViewWillDismissScreen: | ||
-adViewDidDismissScreen: | -bannerViewDidDismissScreen: | ||
-adViewWillLeaveApplication: | हटाया गया | ||
GADNativeCustomTemplateAd | templateID | GADCustomNativeAd.formatID | |
-performClickOnAssetWithKey: |
-performClickOnAssetWithKey: | ||
GADNativeAdImageAd |
preferredImageOrientation | GADNativeAdMediaAdOptions |
|
GADInterstitial | inAppPurchaseDelegate | हटाया गया | |
isReady | हटाया गया | इसके बजाय, canPresentFrom |
|
hasBeenUsed | हटाया गया | ||
-init | -initWithAdUnitID: | ||
-setAdUnitID: | -initWithAdUnitID: | ||
adNetworkClassName | responseInfo |
||
-interstitialWill |
हटाया गया | ||
GADUnifiedNativeAd | videoController | mediaContent.videoController | |
adNetworkClassName | responseInfo |