SDK टूल का माइग्रेशन

इस पेज पर मौजूदा और पिछले वर्शन के लिए माइग्रेशन के बारे में बताया गया है.

10 से v11 पर माइग्रेट करें

कम से कम डिप्लॉयमेंट टारगेट

डिप्लॉयमेंट के कम से कम टारगेट को बढ़ाकर iOS 12 कर दिया गया है.

कम से कम Xcode वर्शन

इस्तेमाल किए जा सकने वाले Xcode वर्शन को बढ़ाकर 15.1 कर दिया गया है.

iOS 12 पर विज्ञापन दिखने बंद हो जाएंगे

Google Mobile Ads SDK के वर्शन 11.0.0 से, सिर्फ़ iOS 13 पर चलने वाले डिवाइसों पर विज्ञापन दिखाए जाते हैं और भी कई नतीजों पर मिलेंगे.

GoogleAppमेज़रमेंट डिपेंडेंसी हटाई गई

वर्शन 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
  • इस डिवाइस को testDeviceIdentifiers में, टेस्ट डिवाइस के तौर पर साफ़ तौर पर बताया गया है.
  • इस डिवाइस को testDeviceIdentifiers में, टेस्ट डिवाइस के तौर पर साफ़ तौर पर बताया गया है.
  • यह एक सिम्युलेटर डिवाइस है.
  • इस डिवाइस का एलान, Ad Manager यूज़र इंटरफ़ेस (यूआई) में साफ़ तौर पर, टेस्ट डिवाइस के तौर पर किया गया है.

वर्शन 9 से 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 ऐप्लिकेशन आईडी की ज़रूरी शर्तें

अब Info.plist में सभी Ad Manager ऐप्लिकेशन के लिए Ad Manager ऐप्लिकेशन आईडी होना ज़रूरी है. साथ ही, ca-app-pub-################~########## फ़ॉर्मैट भी होना ज़रूरी है. ज़्यादा जानकारी के लिए, अपनी Info.plist अपडेट करें देखें.

GoogleAppमेज़रमेंट.xcframework की ज़रूरत

अब सभी Ad Manager ऐप्लिकेशन के लिए GoogleAppमेज़रमेंट.xcframework ज़रूरी है. अगर Cocoapods या Swift Package Manager की मदद से Google Mobile Ads SDK इंस्टॉल किया जाता है, तो आपको कुछ और करने की ज़रूरत नहीं है. अगर फ़्रेमवर्क को मैन्युअल तरीके से इंस्टॉल किया जाता है, तो ज़्यादा जानकारी के लिए मैन्युअल डाउनलोड देखें.

बिटकोड के साथ बिल्डिंग अब काम नहीं करती

अब आपके मोबाइल ऐप्लिकेशन में बिटकोड को बंद करने के लिए, Google Mobile Ads SDK टूल को इंटिग्रेट करना ज़रूरी है.

हटाए गए टाइप

टाइप ज़रूरी जानकारी
GADGender कोई रिप्लेसमेंट नहीं.
GADMRewardBasedVideoAdNetworkAdapterProtocol Select Network पर मौजूद, इनाम वाले सभी मीडिएशन अडैप्टर ने एक साल से ज़्यादा समय से इन प्रोटोकॉल का इस्तेमाल करना बंद कर दिया है. मीडिएशन और कस्टम इवेंट के लिए, GADMediationAdapter का इस्तेमाल करें.
GADMRewardBasedVideoAdNetworkConnectorProtocol

प्रॉपर्टी हटाई गईं

नीचे दी गई प्रॉपर्टी हटा दी गई हैं और उनकी जगह किसी और प्रॉपर्टी का इस्तेमाल नहीं किया जा सकता.

v10.0.0 क्लास प्रॉपर्टी
GADMediationAdRequest userBirthday
userGender
userHasLocation
userLatitude
userLongitude
userLocationAccuracyInMeters
userLocationDescription
GADCustomEventRequest userHasLocation
userLatitude
userLongitude
userLocationAccuracyInMeters
userLocationDescription

वर्शन 8 से v9 पर माइग्रेट करें

iOS 10 पर विज्ञापन दिखना बंद हो गए हैं

Google Mobile Ads SDK के 9.0.0 वर्शन पर काम करने वाला iOS का कम से कम वर्शन iOS 11 है.

Google Mobile Ads SDK के 9.0.0 वर्शन पर अपग्रेड करने से, iOS 10 डिवाइसों पर आपका ऐप्लिकेशन काम नहीं करेगा. हालांकि, उन डिवाइसों पर कोई विज्ञापन नहीं दिखाया जाएगा.

स्टेटस बार कंट्रोल का सख्ती से पालन

9.0.0 और उसके बाद के वर्शन में, फ़ुल-स्क्रीन फ़ॉर्मैट वाले विज्ञापन प्रज़ेंट करने पर, आपके ऐप्लिकेशन को यह पक्का करना होगा कि विज्ञापन, स्टेटस बार को दिखाए जाने की कंट्रोल को कंट्रोल कर सकें. ऐसा न करने पर, आपको लॉग में गड़बड़ी का मैसेज दिखेगा.

आपके ऐप्लिकेशन में व्यू कंट्रोलर के खास लेआउट के आधार पर, हो सकता है कि आपको इसे पक्का करने के लिए कोई बदलाव करने की ज़रूरत न पड़े. तय करें कि आपको अपने विज्ञापन के rootViewController पर childViewControllerForStatusBarHidden प्रॉपर्टी सेट करनी है या नहीं.

विज्ञापन का नाम बदलें adDidpresentFullScreenContent: to adwillpresentFullScreenContent:

ऐप्लिकेशन के काम करने के तरीके में कोई बदलाव नहीं हुआ है. विज्ञापन दिखाने के तरीके को, विज्ञापन दिखाने से ठीक पहले शुरू किया जाता है. इसलिए, नए तरीके के नाम से पता चलता है कि यह तरीका कैसे काम करता है.

GADRequest पर, जगह की जानकारी की सेटिंग वाला एपीआई हटाएं

- (void)setLocationWithLatitude:longitude:accuracy: को GADRequest से मिटा दिया गया है, क्योंकि Google, विज्ञापन दिखाने के लिए जगह की जानकारी के डेटा का इस्तेमाल नहीं करता. अगर ज़रूरी हो, तो तीसरे पक्ष की विज्ञापन नेटवर्क कंपनी को जानकारी देने के लिए तीसरे पक्ष के एपीआई इस्तेमाल करें.

कस्टम इवेंट के इंटरफ़ेस को बंद किया जा रहा है

कस्टम इवेंट, किसी ऐसी विज्ञापन नेटवर्क कंपनी के लिए वॉटरफ़ॉल मीडिएशन जोड़ने के लिए, Ad Manager मीडिएशन की सुविधा देता है जो काम करने वाले विज्ञापन नेटवर्क में शामिल नहीं है.

सभी कस्टम इवेंट प्रोटोकॉल हटा दिए गए हैं. इसके बजाय, उन सुविधाओं के लिए मौजूदा GADMediationAdapter और GADMediationAdEventDelegate प्रोटोकॉल का इस्तेमाल करें. इस बदलाव से ज़्यादा जानकारी मिलती है. साथ ही, इनाम वाले विज्ञापनों और इंटरस्क्रोलर विज्ञापनों के लिए कस्टम इवेंट बनाए जा सकते हैं, जो पहले उपलब्ध नहीं थे.

API

नीचे दी गई टेबल में, संबंधित मीडिएशन अडैप्टर एपीआई से कस्टम इवेंट एपीआई की सूची दी गई है. इन एपीआई का इस्तेमाल वर्शन 9.0.0 से शुरू करके किया जाना चाहिए.

v8 v9
GADCustomEventBanner
GADCustomEvent विक्रेता
GADCustomEventNativeAd
GADMediationAdapter GADMediationBannerAd
GADMediationMediaAd
GADMediationInterscrollerAd
GADMediationRewardedAd
GADMediationNativeAd
delegate GADMediationAdapter क्लास के हर लोड फ़ंक्शन के लोड पूरा होने वाले हैंडलर से डेलिगेट दिखाया जाता है
-init -init
-requestBannerAd:parameter:label:request: -loadBannerForAdConfiguration:completionHandler:
-requestInterstitialAdWithParameter:label:request: -loadInterstitialForAdConfiguration:completionHandler:
-requestNativeAdWithParameter:request:adTypes:options:rootViewController: -loadNativeAdForAdConfiguration:completionHandler:
लागू नहीं -loadInterscrollerAdForAdConfiguration:completionHandler:
लागू नहीं -loadRewardedAdForAdConfiguration:completionHandler:
-presentFromRootViewController: -presentFromViewController:
-handlesUserClicks -handlesUserClicks
-handlesUserImpressions -handlesUserImpressions

डेटा ऐक्सेस करने के तरीके

नीचे दी गई टेबल में, कस्टम इवेंट डेलिगेट के तरीकों से जुड़े मीडिएशन विज्ञापन इवेंट के डेलिगेट के तरीकों की सूची दी गई है. इनका इस्तेमाल वर्शन 9.0.0 से शुरू करके किया जाना चाहिए.

v8 v9
GADCustomEventBanner सुंदर
GADCustomEventदियों के बैज
GADCustomEventNativeAd शरीर के सदस्य
GADMediationAdEventDelegate GADमीडिएशन विज्ञापन
-customEventBanner:didReceiveAd:
-customEventInterstitialDidReceiveAd:
विज्ञापन लोड होने की स्थिति, GADMediationAdapter क्लास में हर लोड फ़ंक्शन के लोड पूरा होने वाले हैंडलर में शामिल की जाती है
-customEventBanner:didFailAd:
-customEventInterstitial:didFailAd:
-customEventBannerWasClicked:
-customEventInterstitialWasClicked:
-reportClick
-customEventBannerWillPresentModal:
-customEventInterstitialWillPresentModal:
-willPresentFullScreenView
-customEventBannerWillDismissModal:
-customEventInterstitialWillDismissModal:
-willDismissFullScreenView
-customEventBannerDidDismissModal:
-customEventInterstitialDidDismissModal:
-didDismissFullScreenView
-customEventBannerWillLeaveApplication:
-customEventInterstitialWillLeaveApplication:
-willBackgroundApplication
viewControllerForPresentingModalView -[GADMediationBannerAd view]

हटाए गए/बदले गए अन्य तरीके और कॉन्सटेंट

मेथड, कॉन्सटेंट या प्रॉपर्टी में बदलाव
पहले से तय किए गए kGAD- स्थिरांक हटाया गया. GAD- से पहले वाले कॉन्सटेंट का इस्तेमाल करें.
GADAdNetworkResponseInfo credentials को हटा दिया गया. इसके बजाय, adUnitMapping का इस्तेमाल करें.
GAMRequest GAMRequest में kGAMSimulatorID के इस्तेमाल पर रोक लगा दी गई है. इसके बजाय, GADRequestConfiguration में GADSimulatorID का इस्तेमाल करें.
GADCustomNativeAd GADCustomNativeAd में mediaView के इस्तेमाल पर रोक लगा दी गई है. इसके बजाय, mediaContent का इस्तेमाल करें.
GoogleMobileAds में इन-ऐप्लिकेशन खरीदारी के एपीआई GoogleMobileAds में मौजूद inAppPurchase एपीआई हटाए गए.

वर्शन 7 से v8 पर माइग्रेट करें

Google Mobile Ads SDK के वर्शन 8.0.0 में कुछ बड़े बदलाव किए गए हैं. साथ ही, इसमें कुछ बड़े बदलाव भी किए गए हैं कुछ एपीआई के नाम बदलना और उन्हें हटाना.

Full-screen Format API के अपडेट

8.0.0 वर्शन और उसके बाद के वर्शन में, इंटरस्टीशियल और इनाम वाले विज्ञापनों का पूरा कलेक्शन एक सामान्य स्क्रीन पर दिखने वाले विज्ञापन का स्टाइल. फ़ुल-स्क्रीन वाले इन नए विज्ञापन एपीआई में दो ये हैं फ़ुल-स्क्रीन विज्ञापन के एपीआई के वर्शन 7 की खास बातें:

  1. स्टैटिक क्लास का तरीका load.

    फ़ुल-स्क्रीन विज्ञापन को लोड करने/दिखाने का पिछला तरीका यहां दिया गया है:

    1. कोई विज्ञापन ऑब्जेक्ट इंस्टेंस बनाएं और उसके रेफ़रंस को होल्ड करें.
    2. कोई ऐसा प्रतिनिधि असाइन करें जो लोड को हैंडल करे और कॉलबैक दिखाएं.
    3. विज्ञापन लोड करें.
    4. देखें कि विज्ञापन isReady का इस्तेमाल करके लोड किया गया है या नहीं.
    5. विज्ञापन दिखाएं.

    वर्शन 8 में, तरीका थोड़ा बदल गया है. लोड कॉलबैक अब मौजूद नहीं हैं का हिस्सा हैं. इसके बजाय, उन्हें load तरीके में पूरा करने वाला हैंडलर:

    1. विज्ञापन क्लास पर स्टैटिक लोड करने का तरीका कॉल करें और लोड होने की जानकारी दें हैंडलर.
    2. लोड होने के बाद वाले कॉलबैक में, लोड किए गए उस विज्ञापन का रेफ़रंस रखें जिसे वापस किया गया.
    3. कोई ऐसा प्रतिनिधि असाइन करें जो शो कॉलबैक मैनेज करता हो.
    4. विज्ञापन दिखाएं.

    इस नए तरीके से ये फ़ायदे मिलते हैं:

    • आपको कभी भी किसी ऐसे विज्ञापन का रेफ़रंस नहीं मिलेगा जो लोड न हुआ हो.
    • लोड होने के दौरान, आपको विज्ञापन ऑब्जेक्ट को होल्ड करने की ज़रूरत नहीं है.
  2. लगातार विज्ञापन इवेंट.

    इवेंट किस तरह का है मौजूदा एपीआई v8 एपीआई
    इवेंट लोड करना 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 एपीआई का इस्तेमाल करके, आपने प्रज़ेंटेशन से पहले विज्ञापन में प्रॉपर्टी के तौर पर 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.");
}

लेगसी GADRewardedBaseVideoAd API को हटाया गया

नया GADRewardedAd एपीआई को सबसे पहले मार्च 2019 में लॉन्च किया गया था. यह एपीआई के तौर पर, लोगों के लिए 18 महीनों से ज़्यादा समय से एपीआई. इसमें लेगसी वर्शन की तुलना में ज़्यादा सुधार किए गए GADRewardedBasedVideoAd एपीआई, जिसमें एक से ज़्यादा एपीआई लोड करने की सुविधा शामिल है एक बार में इनाम वाला विज्ञापन देखें.

SDK टूल के वर्शन 8.0.0 से, लेगसी GADRewardedBasedVideoAd API को हटा दिया गया है.

अडैप्टिव बैनर के लिए स्मार्ट बैनर का बंद होना

स्मार्ट बैनर वाले विज्ञापनों के इस्तेमाल पर रोक लगा दी गई है अडैप्टिव बैनर को बढ़ावा दिया विज्ञापन. अडैप्टिव बैनर की मदद से, डिवाइस की परफ़ॉर्मेंस बेहतर होती है और उसे अपने हिसाब से इस्तेमाल किया जा सकता है विज्ञापन की चौड़ाई सेट कर रहा है. अगर आपको पूरी चौड़ाई वाले बैनर का इस्तेमाल करते रहना है, तो अडैप्टिव बैनर का इस्तेमाल करके किया जाएगा, जैसा कि इस कोड स्निपेट में दिखाया गया है:

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 क्लास वर्शन 7.68.0 एपीआई वर्शन 8.0.0 एपीआई नोट
GADMobileAds +configureWithApplicationID: -startWithCompletionHandler: ऐप्लिकेशन आईडी अब Info.plist में सेट हो गई है.
+disableAutomatedInAppPurchaseReporting -disableAutomatedInAppPurchaseReporting
+disableSDKCrashReporting -disableSDKCrashReporting
GADRequest testDevices GADRequestConfiguration.testdeviceidentifiers TestDeviceIdentifiers प्रॉपर्टी सभी विज्ञापन अनुरोधों पर लागू होती है, जबकि पुरानी testdevices प्रॉपर्टी को हर अनुरोध के हिसाब से सेट किया गया था.
लिंग निकाला गया
जन्मदिन निकाला गया
+sdkVersion GADMobileAds.sharedInstance.sdkVersion
-setBirthdayWithMonth:day:year: निकाला गया
-setLocationWithDescription: -setLocationWithLatitude:longitude:accuracy:
-tagForChildDirectoryटमेंट: [GADMobileAds.sharedInstance.requestConfiguration टैगForChildDirectसिर्फ़मेंट]
GADErrorCode kGADError* GADError* k प्रीफ़िक्स को गड़बड़ी के सभी कोड के कॉन्सटेंट से हटा दिया गया है.
GADBannerView hasAutoRefreshed autoloadEnabled
inAppPurchaseDelegate निकाला गया
mediatedAdView निकाला गया
adNetworkClassName responseInfo.adNetworkClassName
DFPBannerView -setValidAdSizesWithSizes: -setValidAdSizes:
DFPBannerViewOptions -adSizeDelegate निकाला गया
GADBannerViewDelegate -adViewDidReceiveAd: -bannerViewDidReceiveAd:
-adView:didFailToReceiveAdWithError: -bannerView:didFailToReceiveAdWithError:
-adViewWillPresentScreen: -bannerViewWillPresentScreen:
-adViewWillDismissScreen: -bannerViewWillDismissScreen:
-adViewDidDismissScreen: -bannerViewDidDismissScreen:
-adViewWillLeaveApplication: निकाला गया
GADNativeCustomTemplateAd templateID GADCustomNativeAd.formatID
-performClickOnAssetWithKey:customClickHandler: -performClickOnAssetWithKey:
GADNativeAdImageAdLoaderOptions preferredImageOrientation GADNativeAdMediaAdOptions.mediaAspectRatio
GADInterstitial inAppPurchaseDelegate निकाला गया
isReady निकाला गया इसके बजाय, canpresentFromRootViewController:error: का इस्तेमाल करें.
hasBeenUsed निकाला गया
-init -initWithAdUnitID:
-setAdUnitID: -initWithAdUnitID:
adNetworkClassName responseInfo.adNetworkClassName
-interstitialWillLeaveApplication: निकाला गया
GADUnifiedNativeAd videoController mediaContent.videoController
adNetworkClassName responseInfo.adNetworkClassName