इस पेज पर, iOS के लिए Google Mobile Ads SDK के मौजूदा और पिछले वर्शन के माइग्रेशन के बारे में बताया गया है. 12.0.0 वर्शन, फ़रवरी 2025 में रिलीज़ होने की उम्मीद है.
11 से v12 पर माइग्रेट करना
Xcode 16.0 पर अपग्रेड करना
Xcode का कम से कम वर्शन 16.0 हो गया है.
Swift में नाम देने की सुविधा
वर्शन 12.0.0 में, Swift के एपीआई डिज़ाइन के दिशा-निर्देशों में नाम तय करने के नियमों का पालन करने के लिए बदलाव किए गए हैं. इन बदलावों का असर सिर्फ़ Swift पर पड़ेगा. Objective-C एपीआई के नाम में कोई बदलाव नहीं किया गया है.
क्लास के प्रीफ़िक्स में बदलाव
क्लास के प्रीफ़िक्स में ये बदलाव किए गए हैं:
- सभी टाइप के नामों से
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(_:)
को कॉल करने पर, अब 0
की ऊंचाई तब तक दिखती है, जब तक Google Mobile Ads SDK टूल कोई विज्ञापन नहीं दिखाता.
कस्टम सर्च विज्ञापन हटाए गए
इन क्लास को हटा दिया गया है और इनकी जगह कोई नई क्लास नहीं जोड़ी गई है:
GADDynamicHeightSearchBannerView
GADDynamicHeightSearchRequest
GADSearchBannerView
गड़बड़ी कोड में बदलाव
गड़बड़ी के इन कोड में बदलाव किया गया है:
कक्षा | नोट |
---|---|
GADErrorMediationNoFill |
गड़बड़ियां अब GADErrorNoFill के तौर पर दिखती हैं. |
GADErrorReceivedInvalidResponse |
इसे GADErrorReceivedInvalidAdString से बदल दिया गया है. |
GADSimulatorID हटाया गया
GADSimulatorID
को हटा दिया गया है. सिम्युलेटर, डिफ़ॉल्ट रूप से टेस्ट मोड में पहले से ही होते हैं.
कस्टम टारगेटिंग में बदलाव
GADRequest
पर मौजूद customTargeting
डिक्शनरी, अब वैल्यू टाइप के तौर पर String
के बजाय Any
का इस्तेमाल करती है. इससे, एपीआई को संख्या वाली वैल्यू दी जा सकती हैं.
एक्स्ट्रा पैरामीटर में बदलाव
additionalParameters
में पासकोड डालने पर, अब Ad Manager के विज्ञापन अनुरोधों पर कस्टम टारगेटिंग लागू नहीं होती. कस्टम टारगेटिंग लागू करने के लिए, कस्टम टारगेटिंग लेख पढ़ें.
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:
में व्यू कंट्रोलर पैरामीटर की वैल्यू null हो सकती है. अगर nil पास किया जाता है, तो विज्ञापन को व्यू कंट्रोलर के क्रम में सबसे ऊपर मौजूद व्यू कंट्रोलर से दिखाया जाता है.
हटाए गए तरीके
यहां दिए गए तरीके हटा दिए गए हैं.
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 में गड़बड़ी को मैनेज करने के तरीके में बदलाव
GADAdLoader
, 11.0.0 वर्शन से, विज्ञापन अनुरोध तब नहीं करता, जब उसका 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 डिवाइसों पर आपके ऐप्लिकेशन के काम करने में कोई रुकावट नहीं आएगी. हालांकि, उन डिवाइसों पर कोई विज्ञापन नहीं दिखाया जाएगा.
Ad Manager ऐप्लिकेशन आईडी की ज़रूरत
अब सभी Ad Manager ऐप्लिकेशन के लिए, Ad Manager ऐप्लिकेशन आईडी को Info.plist
में डालना ज़रूरी है. साथ ही, इसके लिए ca-app-pub-################~##########
फ़ॉर्मैट का इस्तेमाल करना ज़रूरी है. ज़्यादा जानकारी के लिए, अपना Info.plist अपडेट करना देखें.
GoogleAppMeasurement.xcframework की ज़रूरत
अब सभी Ad Manager ऐप्लिकेशन के लिए, GoogleAppMeasurement.xcframework ज़रूरी है. अगर आपने Cocoapods या Swift Package Manager के ज़रिए Google Mobile Ads SDK इंस्टॉल किया है, तो आपको कुछ करने की ज़रूरत नहीं है. अगर फ़्रेमवर्क को मैन्युअल तरीके से इंस्टॉल किया जाता है, तो ज़्यादा जानकारी के लिए मैन्युअल तरीके से डाउनलोड करना देखें.
बिटकोड की मदद से बिल्ड करने की सुविधा अब काम नहीं करती
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, विज्ञापनों को टारगेट करने के लिए जगह की जानकारी के डेटा का इस्तेमाल नहीं करता. ज़रूरत पड़ने पर, तीसरे पक्ष की विज्ञापन नेटवर्क कंपनियों को जानकारी देने के लिए, तीसरे पक्ष के एपीआई का इस्तेमाल करें.
कस्टम इवेंट इंटरफ़ेस का बंद होना
कस्टम इवेंट की मदद से, Ad Manager मीडिएशन का इस्तेमाल करने वाले पब्लिशर, ऐसे विज्ञापन नेटवर्क के लिए वॉटरफ़ॉल मीडिएशन जोड़ सकते हैं जो काम करने वाले विज्ञापन नेटवर्क में शामिल नहीं है.
सभी कस्टम इवेंट प्रोटोकॉल बंद कर दिए गए हैं. इसके बजाय, वही सुविधाएं पाने के लिए, मौजूदा
GADMediationAdapter
और
GADMediationAdEventDelegate
प्रोटोकॉल का इस्तेमाल करें. इस बदलाव से, आपको इनाम वाले विज्ञापनों और इंटरस्क्रोलर विज्ञापनों के लिए कस्टम इवेंट बनाने की सुविधा मिलती है. ये विज्ञापन पहले उपलब्ध नहीं थे.
API
नीचे दी गई टेबल में, कस्टम इवेंट एपीआई से जुड़े ऐसे मीडिएशन अडैप्टर एपीआई की सूची दी गई है जिनका इस्तेमाल 9.0.0 वर्शन से किया जाना चाहिए.
v8 | v9 | |
---|---|---|
GADCustomEventBanner GADCustomEventInterstitial GADCustomEventNativeAd |
GADMediationAdapter | GADMediationBannerAd GADMediationInterstitialAd GADMediationInterscrollerAd GADMediationRewardedAd GADMediationNativeAd |
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 का इस्तेमाल करें.
|
GAMRequest
|
GAMRequest में kGAMSimulatorID का इस्तेमाल नहीं किया जा सकता.
इसके बजाय, GADRequestConfiguration में GADSimulatorID का इस्तेमाल करें.
|
GADCustomNativeAd
|
GADCustomNativeAd में mediaView का इस्तेमाल नहीं किया जा सकता.
इसके बजाय, mediaContent का इस्तेमाल करें.
|
GoogleMobileAds में In-App Purchase API |
GoogleMobileAds में inAppPurchase एपीआई हटा दिए गए थे.
|
v7 से v8 पर माइग्रेट करना
Google Mobile Ads SDK के वर्शन 8.0.0 में कुछ बड़े बदलाव किए गए हैं. साथ ही, कुछ एपीआई के नाम बदले गए हैं और कुछ हटाए भी गए हैं.
फ़ुल-स्क्रीन फ़ॉर्मैट वाले एपीआई के अपडेट
वर्शन 8.0.0 से, इंटरस्टीशियल और इनाम वाले विज्ञापनों में एक जैसा फ़ुल स्क्रीन विज्ञापन स्टाइल दिखता है. इससे, विज्ञापनों को एक जैसा दिखाने में मदद मिलती है. फ़ुल स्क्रीन वाले इन नए विज्ञापन एपीआई में, वर्शन 7 के फ़ुल स्क्रीन वाले विज्ञापन एपीआई से दो मुख्य फ़र्क़ हैं:
स्टैटिक क्लास का तरीका
load
.फ़ुल-स्क्रीन विज्ञापन को लोड/दिखाने का पिछला तरीका यह था:
- विज्ञापन ऑब्जेक्ट का इंस्टेंस बनाएं और उसका रेफ़रंस रखें.
- एक प्रतिनिधि असाइन करें जो लोड और शो कॉलबैक को मैनेज करता है.
- कोई विज्ञापन लोड करें.
- देखें कि विज्ञापन
isReady
का इस्तेमाल करके लोड हुआ है या नहीं. - विज्ञापन दिखाएं.
आठवें वर्शन में, इस प्रोसेस में थोड़ा बदलाव किया गया है. लोड कॉलबैक अब डिलीगेट का हिस्सा नहीं हैं. इसके बजाय, इन्हें
load
तरीके में, पूरे होने के हैंडलर के तौर पर पास किया जाता है:- विज्ञापन क्लास पर स्टैटिक लोड करने का तरीका कॉल करें और लोड पूरा होने के बाद होने वाली कार्रवाई को मैनेज करने वाला फ़ंक्शन दें.
- लोड पूरा होने के कॉलबैक में, लोड किए गए विज्ञापन का रेफ़रंस रखें.
- शो कॉलबैक को मैनेज करने वाला कोई प्रतिनिधि असाइन करें.
- विज्ञापन दिखाएं.
नए तरीके से ये फ़ायदे मिलते हैं:
- आपको ऐसे विज्ञापन का रेफ़रंस कभी नहीं मिलेगा जो लोड नहीं हुआ है.
- विज्ञापन ऑब्जेक्ट लोड होने के दौरान, आपको उसे होल्ड करने की ज़रूरत नहीं है.
एक जैसे विज्ञापन इवेंट.
इवेंट किस तरह का है मौजूदा एपीआई v8 API इवेंट लोड करना GADInterstitialDelegate
याGADRewardedAdDelegate
GAMInterstitialAdLoadCompletionHandler
याGADRewardedAdLoadCompletionHandler
प्रज़ेंटेशन इवेंट GADFullScreenContentDelegate
पहले, किसी भी विज्ञापन इवेंट को सुनने के लिए, आपको एक ऐसी क्लास रजिस्टर करनी होती थी जो इंटरस्टीशियल की डेलिगेट प्रॉपर्टी में
GADInterstitialDelegate
प्रोटोकॉल को लागू करती हो. इसके अलावा, आपको एक ऐसी क्लास भी रजिस्टर करनी होती थी जो इनाम वाले विज्ञापन की डेलिगेट प्रॉपर्टी मेंGADRewardedAdDelegate
प्रोटोकॉल को लागू करती हो. यह इस बात पर निर्भर करता है कि किस फ़ॉर्मैट का इस्तेमाल किया जा रहा है. इस ही डेलिगेट में, विज्ञापन के लोड होने और दिखाए जाने के लाइफ़ साइकल, दोनों से जुड़े तरीके थे.वर्शन 8 में, लोड और प्रज़ेंटेशन इवेंट अलग-अलग होते हैं. अब विज्ञापन दिखाने से पहले, किसी भी समय
GADFullScreenContentDelegate
को रजिस्टर किया जा सकता है. इसके लिए, विज्ञापन लोड करने से पहले एक प्रतिनिधि सेट करने की ज़रूरत नहीं है. विज्ञापन लोड होने के इवेंट, हर फ़ॉर्मैट के लिए खास होते हैं. ये इवेंट, लोड करने के तरीके में पास किए गए लोड पूरा होने के एक हैंडलर पर मूव हो जाते हैं.
मध्यवर्ती
विज्ञापन लोड करना
यहां दिए गए कोड स्निपेट में, इंटरस्टीशियल विज्ञापन लोड करने का तरीका बताया गया है. साथ ही, विज्ञापन लोड होने या न होने पर होने वाले इवेंट के बारे में जानकारी दी गई है.
v7
Swift
import GoogleMobileAds import UIKit class ViewController: UIViewController, GADInterstitialDelegate { var interstitial: DFPInterstitial! override func viewDidLoad() { super.viewDidLoad() interstitial = DFPInterstitial(adUnitID: "/21775744923/example/interstitial") interstitial.delegate = self let request = GAMRequest() interstitial.load(request) } /// Tells the delegate an ad request succeeded. func interstitialDidReceiveAd(_ ad: DFPInterstitial) { print("Interstitial ad loaded.") } /// Tells the delegate an ad request failed. func interstitial(_ ad: DFPInterstitial, didFailToReceiveAdWithError error: GADRequestError) { print("Interstitial ad failed to load with error: \(error.localizedDescription)") } }
Objective-C
@import GoogleMobileAds; @import UIKit; @interface ViewController ()@property(nonatomic, strong) DFPInterstitial *interstitial; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.interstitial = [[DFPInterstitial alloc] initWithAdUnitID:@"/21775744923/example/interstitial"]; self.interstitial.delegate = self; GAMRequest *request = [GAMRequest request]; [self.interstitial loadRequest:request]; } /// Tells the delegate an ad request succeeded. - (void)interstitialDidReceiveAd:(DFPInterstitial *)ad { NSLog(@"Insterstitial ad loaded."); } /// Tells the delegate an ad request failed. - (void)interstitial:(DFPInterstitial *)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: GAMInterstitialAd? override func viewDidLoad() { super.viewDidLoad() let request = GAMRequest() GAMInterstitialAd.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) GAMInterstitialAd *interstitial; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; GAMRequest *request = [GAMRequest request]; [GAMInterstitialAd loadWithAdUnitID:@"/21775744923/example/interstitial" request:request completionHandler:^(GAMInterstitialAd *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 = DFPInterstitial(adUnitID: "/21775744923/example/interstitial") interstitial.delegate = self ... } /// Tells the delegate that an interstitial will be presented. func interstitialWillPresentScreen(_ ad: DFPInterstitial) { print("Interstitial ad will be presented.") } /// Tells the delegate the interstitial is to be animated off the screen. func interstitialWillDismissScreen(_ ad: DFPInterstitial) { print("Interstitial ad will be dismissed.") } /// Tells the delegate the interstitial had been animated off the screen. func interstitialDidDismissScreen(_ ad: DFPInterstitial) { 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: DFPInterstitial) { print("Interstitial ad will leave application.") }
Objective-C
- (void)viewDidLoad { [super viewDidLoad]; self.interstitial = [[DFPInterstitial alloc] initWithAdUnitID:"/21775744923/example/interstitial"]; self.interstitial.delegate = self; ... } /// Tells the delegate that an interstitial will be presented. - (void)interstitialWillPresentScreen:(DFPInterstitial *)ad { NSLog(@"Interstitial ad will be presented."); } /// Tells the delegate the interstitial is to be animated off the screen. - (void)interstitialWillDismissScreen:(DFPInterstitial *)ad { NSLog(@"Interstitial ad will be dismissed."); } /// Tells the delegate the interstitial had been animated off the screen. - (void)interstitialDidDismissScreen:(DFPInterstitial *)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:(DFPInterstitial *)ad { NSLog(@"Interstitial ad will leave application."); }
v8
Swift
override func viewDidLoad() { super.viewDidLoad() let request = GAMRequest() GAMInterstitialAd.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]; GAMRequest *request = [GAMRequest request]; [GAMInterstitialAd loadWithAdUnitID:@"/21775744923/example/interstitial" request:request completionHandler:^(GAMInterstitialAd *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(GAMRequest()) { 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; GAMRequest *request = [GAMRequest 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 = GAMRequest() 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]; GAMRequest *request = [GAMRequest 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
एपीआई के वर्शन 7 के साथ, 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 = GAMRequest() 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]; GAMRequest *request = [GAMRequest 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."); }
GADRewardBasedVideoAd के लेगसी एपीआई को हटाना
नया GADRewardedAd
API, मार्च 2019 में पहली बार लॉन्च किया गया था. यह 18 महीने से, इनाम वाला पसंदीदा API है. इसमें, लेगसी 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:
तरीकों का इस्तेमाल किया जा सकता है. OS-लेवल एपीआई का इस्तेमाल करके, आपको यह सूचना मिलती है कि उपयोगकर्ता आपके ऐप्लिकेशन से कब बाहर निकलते हैं. भले ही, यह विज्ञापन इंटरैक्शन की वजह से हो या नहीं.
ध्यान दें कि 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 |