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

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

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

इस गाइड में, 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 पैकेज इंस्टॉल करें.

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

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

CocoaPods

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

  1. अपने प्रोजेक्ट की Podfile खोलें और इस लाइन को अपने ऐप्लिकेशन के target बिल्ड कॉन्फ़िगरेशन में जोड़ें:

    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. अपने टारगेट की General सेटिंग में, Frameworks, Libraries, and Embedded Content पर जाएं.

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

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

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

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

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

पूरी तरह से तैयार उदाहरण

<key>GADApplicationIdentifier</key>
<!-- Sample Ad Manager 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 को अपने Ad Manager ऐप्लिकेशन आईडी से बदलें. टेस्टिंग के दौरान, पिछले उदाहरण में दिखाए गए सैंपल ऐप्लिकेशन आईडी का इस्तेमाल करें.

अपने ऐप्लिकेशन को तेज़ी से शुरू करने के लिए, अपने यील्ड ग्रुप को चुनिंदा ऐप्लिकेशन से लिंक करें. अगर कोई यील्ड ग्रुप iOS को टारगेट करता है, लेकिन किसी ऐप्लिकेशन से लिंक नहीं है, तो Google उस ग्रुप को आपके खाते में मौजूद सभी iOS ऐप्लिकेशन पर भेज देता है. इस तरीके से, परफ़ॉर्मेंस धीमी हो सकती है.

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

विज्ञापनों को लोड करने से पहले, GADMobileAds.sharedInstance प्रॉपर्टी से start() तरीके को कॉल करके, Google Mobile Ads SDK को शुरू करें. यह तरीका, 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];

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

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

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

Ad Manager में ये विज्ञापन फ़ॉर्मैट उपलब्ध हैं:

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