विज्ञापन दिखाने और रेवेन्यू पाने के लिए, अपने 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 (सुझाया गया)
अपने प्रोजेक्ट में पैकेज डिपेंडेंसी जोड़ने के लिए, यह तरीका अपनाएं:
- Xcode खोलें.
- File > Add Package Dependencies... पर जाएं.
Google Mobile Ads SDK Swift पैकेज इंस्टॉल करें.
दिखने वाले प्रॉम्प्ट में, Google Mobile Ads Swift Package GitHub रिपॉज़िटरी खोजें:
https://github.com/googleads/swift-package-manager-google-mobile-ads.gitGoogle Mobile Ads SDK Swift Package का वह वर्शन चुनें जिसका आपको इस्तेमाल करना है. नए प्रोजेक्ट के लिए, हमारा सुझाव है कि अगले मुख्य वर्शन तक का इस्तेमाल करें.
CocoaPods
CocoaPods का इस्तेमाल करने के लिए, यह तरीका अपनाएं:
अपने प्रोजेक्ट की Podfile खोलें और अपने ऐप्लिकेशन के
targetbuild configuration में यह लाइन जोड़ें:pod 'Google-Mobile-Ads-SDK'टर्मिनल में, यह कमांड चलाएं:
pod install --repo-update
Xcode 27 के लिए डिप्लॉयमेंट टारगेट कॉन्फ़िगर करें
Xcode 27 के लिए, सभी टारगेट के लिए iOS 15.0 या इसके बाद का वर्शन होना ज़रूरी है. Google Mobile Ads SDK iOS 13.0 के साथ काम करता है. इसलिए, CocoaPods का इस्तेमाल करते समय Xcode 27 बिल्ड फ़ेल हो जाते हैं.
इस समस्या को हल करने के लिए, यह तरीका अपनाएं:
अपने प्रोजेक्ट का
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पॉड फिर से इंस्टॉल करने के लिए, यह कमांड चलाएं:
pod install --repo-update
मैन्युअल तरीके से डाउनलोड करना
Google Mobile Ads SDK को मैन्युअल तरीके से डाउनलोड करने के लिए, यह तरीका अपनाएं:
- डाउनलोड करें Google Mobile Ads SDK.
googlemobileadssdkios.zipपैकेज को एक्सट्रैक्ट करें.अपने Xcode प्रोजेक्ट में, ये फ़्रेमवर्क जोड़ें:
GoogleMobileAds.xcframeworkUserMessagingPlatform.xcframework
अपने टारगेट की सामान्य सेटिंग में जाकर, फ़्रेमवर्क, लाइब्रेरी, और एम्बेड किया गया कॉन्टेंट पर जाएं.
पुष्टि करें कि आपने
GoogleMobileAds.xcframeworkऔरUserMessagingPlatform.xcframeworkको एम्बेड और साइन करें पर सेट किया हो.अपने प्रोजेक्ट की बिल्ड सेटिंग में जाकर, यह काम करें:
/usr/lib/swiftपाथ को Runpath Search Paths में जोड़ें.- Other Linker Flags में
-ObjClinker फ़्लैग जोड़ें.
अपनी Info.plist फ़ाइल अपडेट करना
अपने ऐप्लिकेशन की Info.plist फ़ाइल में, ये कुंजियां जोड़ें:
GADApplicationIdentifierकुंजी, जिसकी स्ट्रिंग वैल्यू आपके Ad Manager ऐप्लिकेशन का आईडी है. यह आईडी, Ad Manager के यूज़र इंटरफ़ेस (यूआई) में मिलता है और इसका फ़ॉर्मैटca-app-pub-################~##########होता है.SKAdNetworkItemsकुंजी. इस कुंजी में, Googlecstr6suwn9.skadnetworkऔर तीसरे पक्ष के चुनिंदा खरीदारों के लिएSKAdNetworkIdentifierवैल्यू शामिल होती हैं.
पूरा उदाहरण
<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 शुरू करें
विज्ञापनों को लोड करने से पहले, 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];
शुरू करते समय, Google Mobile Ads SDK, विज्ञापनों को प्रीलोड कर सकता है या startWithCompletionHandler: तरीके को कॉल करते समय तीसरे पक्ष के एसडीके को शुरू कर सकता है. अगर आपको यूरोपियन इकनॉमिक एरिया (ईईए), यूनाइटेड किंगडम (यूके) या स्विट्ज़रलैंड में रहने वाले लोगों से सहमति लेनी है, तो अनुरोध के हिसाब से फ़्लैग सेट करें. अगर आपको अनुरोध के हिसाब से फ़्लैग सेट करने हैं, तो पक्का करें कि आपने Google Mobile Ads SDK को शुरू करने से पहले फ़्लैग सेट कर दिए हों. ज़्यादा जानकारी के लिए, टारगेटिंग लेख पढ़ें.
कोई विज्ञापन फ़ॉर्मैट चुनें
Google Mobile Ads SDK इंपोर्ट करने के बाद, लागू करने के लिए कोई विज्ञापन फ़ॉर्मैट चुना जा सकता है.
Ad Manager में ये विज्ञापन फ़ॉर्मैट उपलब्ध हैं:
| विज्ञापन फ़ॉर्मैट | ब्यौरा | दस्तावेज़ |
|---|---|---|
| बैनर | यह आपके ऐप्लिकेशन के लेआउट के किसी सेक्शन में रेक्टैंगल के आकार वाले विज्ञापन दिखाता है. यह विज्ञापन, तय किए गए इंटरवल पर अपने-आप रीफ़्रेश होता है. जब उपयोगकर्ता एक ही स्क्रीन पर बने रहते हैं, तब उन्हें समय-समय पर ये विज्ञापन दिखते हैं. | बैनर विज्ञापन सेट अप करना |
| मध्यवर्ती | यह विज्ञापन, आपके ऐप्लिकेशन में पूरे पेज को कवर करने वाले विज्ञापन दिखाता है. इसे अपने ऐप्लिकेशन के इंटरफ़ेस में इस तरह सेट करें कि यह तय समय और ट्रांज़िशन के दौरान दिखे. जैसे, किसी गेमिंग ऐप्लिकेशन में लेवल पूरा होने के बाद. | पेज पर अचानक दिखने वाले विज्ञापन |
| मूल भाषा वाला | इसकी मदद से, ऐप्लिकेशन में मौजूद ऐसेट को अपनी पसंद के मुताबिक बनाया जा सकता है. जैसे, हेडलाइन और कॉल-टू-ऐक्शन. विज्ञापन को पसंद के मुताबिक बनाने पर, ऐसे विज्ञापन बनाए जाते हैं जो आपके ऐप्लिकेशन के विज़ुअल डिज़ाइन से मेल खाते हैं. | नेटिव विज्ञापन लोड करना |
| इनाम दिया गया | उपयोगकर्ताओं को गेम खेलने, सर्वे में हिस्सा लेने या वीडियो देखने पर, ऐप्लिकेशन में इनाम मिलते हैं. जैसे, कॉइन या पॉइंट. विज्ञापन यूनिट के लिए इनाम सेट किए जा सकते हैं. साथ ही, यह भी बताया जा सकता है कि उपयोगकर्ताओं को मिलने वाले इनाम की वैल्यू और आइटम क्या हैं. | इनाम वाले विज्ञापन |
| इनाम वाला इंटरस्टीशियल विज्ञापन | इसकी मदद से, ऐप्लिकेशन में ट्रांज़िशन के दौरान दिखने वाले विज्ञापनों के लिए, कॉइन या खेलने के कुछ और मौके जैसे इनाम दिए जाते हैं. | इनाम वाले इंटरस्टीशियल विज्ञापन |
| ऐप्लिकेशन खोलने पर दिखने वाला विज्ञापन | यह विज्ञापन तब दिखता है, जब उपयोगकर्ता आपके ऐप्लिकेशन को खोलते हैं या उस पर वापस आते हैं. यह विज्ञापन, लोड हो रही स्क्रीन को ओवरले करता है. | ऐप्लिकेशन खोलने पर दिखने वाले विज्ञापन |