Google Mobile Ads SDK सेट अप करना

प्लैटफ़ॉर्म चुनें: Android iOS Unity Flutter Android (लेगसी)

विज्ञापनों को दिखाने और रेवेन्यू जनरेट करने के लिए, अपने iOS ऐप्लिकेशन में Google Mobile Ads SDK को इंटिग्रेट करें. अपने प्रोजेक्ट को तैयार करने के लिए, विज्ञापन का अनुरोध करने से पहले Google Mobile Ads SDK को इंपोर्ट और शुरू करें.

अगर आपने अपने iOS ऐप्लिकेशन में Firebase को शामिल किया है, तो अपने iOS प्रोजेक्ट में AdMob का इस्तेमाल शुरू करना लेख पढ़ें.

इस गाइड में, Google Mobile Ads SDK को इंपोर्ट और शुरू करने के साथ-साथ विज्ञापन फ़ॉर्मैट चुनने के बारे में बताया गया है.

ज़रूरी शर्तें

जारी रखने से पहले, पक्का करें कि आपके पास ये चीज़ें हों:

  • Xcode 16.0 या इसके बाद के वर्शन का इस्तेमाल करें.
  • iOS 13.0 या इसके बाद के वर्शन को टारगेट करें.

Google Mobile Ads SDK इंपोर्ट करें

Google Mobile Ads SDK इंपोर्ट करने के लिए, इनमें से कोई एक सेक्शन पूरा करें:

Swift Package Manager (सुझाया गया)

अपने प्रोजेक्ट में पैकेज डिपेंडेंसी जोड़ने के लिए, यह तरीका अपनाएं:

  1. Xcode खोलें.
  2. File > Add Package Dependencies... पर जाएं.
  3. Google Mobile Ads SDK Swift Package इंस्टॉल करें.

  4. दिखने वाले प्रॉम्प्ट में, Google Mobile Ads Swift Package GitHub रिपॉज़िटरी खोजें:

    https://github.com/googleads/swift-package-manager-google-mobile-ads.git
    
  5. Google Mobile Ads SDK Swift Package का वह वर्शन चुनें जिसे आपको इस्तेमाल करना है. हमारा सुझाव है कि नए प्रोजेक्ट के लिए, अगले मुख्य वर्शन तक का इस्तेमाल करें.

CocoaPods

CocoaPods का इस्तेमाल करने के लिए, यह तरीका अपनाएं:

  1. अपने प्रोजेक्ट का Podfile खोलें और अपने ऐप्लिकेशन के target build configuration में यह लाइन जोड़ें:

    pod 'Google-Mobile-Ads-SDK'
    
  2. टर्मिनल में, यह कमांड चलाएं:

    pod install --repo-update

Xcode 27 के लिए डिप्लॉयमेंट टारगेट कॉन्फ़िगर करें

Xcode 27 के लिए, सभी टारगेट के लिए iOS 15.0 या इसके बाद का वर्शन होना ज़रूरी है. Google Mobile Ads SDK iOS 13.0 के साथ काम करता है. इसलिए, CocoaPods का इस्तेमाल करते समय Xcode 27 बिल्ड काम नहीं करते.

इस समस्या को हल करने के लिए, यह तरीका अपनाएं:

  1. अपने प्रोजेक्ट का Podfile खोलें और एक post_install हुक जोड़ें. यह हुक, डिप्लॉयमेंट टारगेट को 15.0 पर सेट करता है. अगर आपके पास post_install ब्लॉक है, तो अपने मौजूदा ब्लॉक में इनर लूप जोड़ें.

    यहां दिए गए उदाहरण में, सभी पॉड टारगेट के लिए IPHONEOS_DEPLOYMENT_TARGET कुंजी को 15.0 पर सेट किया गया है:

    post_install do |installer|
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0'
        end
      end
    end
    
  2. अपने पॉड फिर से इंस्टॉल करने के लिए, यह कमांड चलाएं:

    pod install --repo-update

मैन्युअल तरीके से डाउनलोड करना

Google Mobile Ads SDK को मैन्युअल तरीके से डाउनलोड करने के लिए, यह तरीका अपनाएं:

  1. डाउनलोड करें Google Mobile Ads SDK.
  2. googlemobileadssdkios.zip पैकेज को एक्सट्रैक्ट करें.
  3. अपने Xcode प्रोजेक्ट में, ये फ़्रेमवर्क जोड़ें:

    • GoogleMobileAds.xcframework
    • UserMessagingPlatform.xcframework
  4. अपने टारगेट की सामान्य सेटिंग में जाकर, फ़्रेमवर्क, लाइब्रेरी, और एम्बेड किया गया कॉन्टेंट पर जाएं.

  5. पुष्टि करें कि आपने GoogleMobileAds.xcframework और UserMessagingPlatform.xcframework को एम्बेड करें और साइन करें पर सेट किया हो.

  6. अपने प्रोजेक्ट की बिल्ड सेटिंग में जाकर, यह तरीका अपनाएं:

    • Runpath Search Paths में /usr/lib/swift पाथ जोड़ें.
    • -ObjC लिंकर फ़्लैग को Other Linker Flags में जोड़ें.

अपनी Info.plist फ़ाइल अपडेट करना

अपने ऐप्लिकेशन की Info.plist फ़ाइल में, ये कुंजियां जोड़ें:

पूरा उदाहरण

<key>GADApplicationIdentifier</key>
<!-- Sample AdMob app ID: ca-app-pub-3940256099942544~1458002511 -->
<string>SAMPLE_APP_ID</string>
<key>SKAdNetworkItems</key>
<array>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>cstr6suwn9.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>4fzdc2evr5.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>2fnua5tdw4.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>ydx93a7ass.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>p78axxw29g.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>v72qych5uu.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>ludvb6z3bs.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>cp8zw746q7.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>3sh42y64q3.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>c6k4g5qg8m.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>s39g8k73mm.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>wg4vff78zm.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>3qy4746246.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>f38h382jlk.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>hs6bdukanm.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>mlmmfzh3r3.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>v4nxqhlyqp.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>wzmmz9fp6w.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>su67r6k2v3.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>yclnxrl5pm.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>t38b2kh725.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>7ug5zh24hu.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>gta9lk7p23.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>vutu7akeur.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>y5ghdn5j9k.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>v9wttpbfk9.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>n38lu8286q.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>47vhws6wlr.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>kbd757ywx3.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>9t245vhmpl.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>a2p9lx4jpn.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>22mmun2rn5.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>44jx6755aq.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>k674qkevps.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>4468km3ulz.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>2u9pt9hc89.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>8s468mfl3y.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>klf5c3l5u5.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>ppxm28t8ap.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>kbmxgpxpgc.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>uw77j35x4d.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>578prtvx9j.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>4dzt52r2t5.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>tl55sbb4fm.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>c3frkrj4fj.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>e5fvkxwrpn.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>8c4e2ghe7u.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>3rd42ekr43.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>97r2b46745.skadnetwork</string>
  </dict>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>3qcr597p9d.skadnetwork</string>
  </dict>
</array>

SAMPLE_APP_ID की जगह अपना AdMob ऐप्लिकेशन आईडी डालें. जांच करते समय, पिछले उदाहरण में दिखाया गया सैंपल ऐप्लिकेशन आईडी इस्तेमाल करें.

अगर आपने अब तक AdMob खाता नहीं बनाया है और कोई ऐप्लिकेशन रजिस्टर नहीं किया है, तो अभी ऐसा करें.

Google Mobile Ads SDK शुरू करें

विज्ञापन लोड करने से पहले, Google Mobile Ads SDK को शुरू करें. इसके लिए, GADMobileAds.sharedInstance प्रॉपर्टी से start() तरीके को कॉल करें. यह तरीका, Google Mobile Ads SDK और मीडिएशन अडैप्टर की प्रोसेसिंग पूरी होने के बाद या 30 सेकंड के बाद, पूरा होने पर काम आने वाले हैंडलर को कॉल करता है.

यहां दिए गए उदाहरण में, Google Mobile Ads SDK को शुरू करने का तरीका बताया गया है:

Swift

// Initialize the Google Mobile Ads SDK.
MobileAds.shared.start()

SwiftUI

// Initialize the Google Mobile Ads SDK.
MobileAds.shared.start()

Objective-C

// Initialize the Google Mobile Ads SDK.
[GADMobileAds.sharedInstance startWithCompletionHandler:nil];

शुरू करते समय, startWithCompletionHandler: तरीके को कॉल करने पर, Google Mobile Ads SDK विज्ञापनों को पहले से लोड कर सकता है या तीसरे पक्ष के एसडीके शुरू कर सकता है. अगर आपको यूरोपियन इकनॉमिक एरिया (ईईए), यूनाइटेड किंगडम (यूके) या स्विट्ज़रलैंड में रहने वाले लोगों से सहमति लेनी है, तो अनुरोध के हिसाब से फ़्लैग सेट करें. अगर आपको अनुरोध के हिसाब से फ़्लैग सेट करने हैं, तो पक्का करें कि आपने Google Mobile Ads SDK को शुरू करने से पहले फ़्लैग सेट कर दिए हों. ज़्यादा जानकारी के लिए, टारगेटिंग लेख पढ़ें.

कोई विज्ञापन फ़ॉर्मैट चुनें

Google Mobile Ads SDK इंपोर्ट करने के बाद, लागू करने के लिए कोई विज्ञापन फ़ॉर्मैट चुना जा सकता है.

AdMob, ये विज्ञापन फ़ॉर्मैट उपलब्ध कराता है:

विज्ञापन फ़ॉर्मैट ब्यौरा दस्तावेज़
बैनर यह आपके ऐप्लिकेशन के लेआउट के किसी सेक्शन में रेक्टैंगल के आकार वाले विज्ञापन दिखाता है. यह विज्ञापन, तय किए गए समय अंतराल पर अपने-आप रीफ़्रेश होता है. जब उपयोगकर्ता एक ही स्क्रीन पर बने रहते हैं, तब उन्हें ये विज्ञापन समय-समय पर दिखते हैं. बैनर विज्ञापन सेट अप करना
मध्यवर्ती यह विज्ञापन, आपके ऐप्लिकेशन में पूरे पेज को कवर करने वाले विज्ञापन दिखाता है. इसे अपने ऐप्लिकेशन के इंटरफ़ेस में इस तरह सेट करें कि यह तय समय और ट्रांज़िशन के दौरान दिखे. उदाहरण के लिए, किसी गेमिंग ऐप्लिकेशन में लेवल पूरा होने के बाद. पेज पर अचानक दिखने वाले विज्ञापन
मूल भाषा वाला इसकी मदद से, अपने ऐप्लिकेशन में हेडलाइन और कॉल-टू-ऐक्शन जैसी ऐसेट को पसंद के मुताबिक बनाया जा सकता है. विज्ञापन को पसंद के मुताबिक बनाने पर, ऐसे विज्ञापन बनाए जाते हैं जो आपके ऐप्लिकेशन के विज़ुअल डिज़ाइन से मेल खाते हैं. नेटिव विज्ञापन लोड करना
इनाम दिया गया उपयोगकर्ता, गेम खेलने, सर्वे में हिस्सा लेने या वीडियो देखने पर, इन-ऐप्लिकेशन इनाम पाते हैं. जैसे, सिक्के या पॉइंट. आपके पास विज्ञापन यूनिट के लिए इनाम सेट करने का विकल्प होता है. साथ ही, उपयोगकर्ताओं को मिलने वाले इनाम की वैल्यू और आइटम भी तय किए जा सकते हैं. इनाम वाले विज्ञापन
इनाम वाला इंटरस्टीशियल विज्ञापन इसकी मदद से, ऐप्लिकेशन में ट्रांज़िशन के दौरान दिखने वाले विज्ञापनों के लिए, सिक्के या खेलने के कुछ और मौके जैसे इनाम दिए जा सकते हैं. इनाम वाले इंटरस्टीशियल विज्ञापन
ऐप्लिकेशन खोलने पर दिखने वाला विज्ञापन यह विज्ञापन तब दिखता है, जब उपयोगकर्ता आपके ऐप्लिकेशन को खोलते हैं या उस पर वापस आते हैं. यह विज्ञापन, लोड हो रही स्क्रीन को ओवरले करता है. ऐप्लिकेशन खोलने पर दिखने वाले विज्ञापन