विज्ञापन दिखाने और कमाई करने की दिशा में, Google Mobile Ads SDK को ऐप्लिकेशन में इंटिग्रेट करना पहला कदम है. SDK टूल जोड़ने के बाद, इस्तेमाल किए जा सकने वाले एक या इससे ज़्यादा विज्ञापन फ़ॉर्मैट लागू किए जा सकते हैं.
ज़रूरी शर्तें
- Xcode 15.3 या इसके बाद के वर्शन का इस्तेमाल करना
- iOS 12.0 या इसके बाद के वर्शन को टारगेट करें
मोबाइल विज्ञापन SDK टूल इंपोर्ट करें
Google Mobile Ads SDK को इंपोर्ट करने के लिए, इनमें से किसी एक तरीके का इस्तेमाल करें.
CocoaPods (पसंदीदा)
CocoaPods का इस्तेमाल करना, SDK टूल को iOS प्रोजेक्ट में इंपोर्ट करने का सबसे आसान तरीका है. अपने प्रोजेक्ट की Podfile खोलें और इस लाइन को अपने ऐप्लिकेशन के टारगेट में जोड़ें:
pod 'Google-Mobile-Ads-SDK'
फिर कमांड लाइन से चलाएं:
pod install --repo-update
अगर आपने CocoaPods का इस्तेमाल पहले कभी नहीं किया है, तो Podfiles बनाने और इस्तेमाल करने के तरीके के बारे में जानकारी के लिए, उनके आधिकारिक दस्तावेज़ देखें.
Swift पैकेज मैनेजर
Google Mobile Ads SDK, 9.0.0 और इसके बाद के वर्शन में Swift पैकेज मैनेजर के साथ काम करता है. Swift पैकेज इंपोर्ट करने के लिए यह तरीका अपनाएं:
Xcode में, Google Mobile Ads Swift पैकेज इंस्टॉल करने के लिए, फ़ाइल > पैकेज जोड़ें... पर जाएं.
स्क्रीन पर दिख रहे प्रॉम्प्ट में, Google Mobile Ads Swift पैकेज GitHub रिपॉज़िटरी खोजें:
https://github.com/googleads/swift-package-manager-google-mobile-ads.git
Google Mobile Ads Swift पैकेज का वह वर्शन चुनें जिसका आपको इस्तेमाल करना है. नए प्रोजेक्ट के लिए, हमारा सुझाव है कि आप अगला मेजर वर्शन इस्तेमाल करें.
आपका काम पूरा होने के बाद, Xcode आपकी पैकेज डिपेंडेंसी को ठीक करना और उन्हें बैकग्राउंड में डाउनलोड करना शुरू कर देगा. पैकेज डिपेंडेंसी जोड़ने के तरीके के बारे में ज़्यादा जानकारी के लिए, Apple का लेख पढ़ें.
मैन्युअल डाउनलोड
अपने Xcode प्रोजेक्ट में Google Mobile Ads SDK और
Embed & Sign
नीचे दिए गए फ़्रेमवर्क को डाउनलोड करें:GoogleMobileAds.xcframework
UserMessagingPlatform.xcframework
अपने प्रोजेक्ट की बिल्ड सेटिंग में,
-ObjC
लिंकर फ़्लैग को अन्य लिंकर फ़्लैग में जोड़ें:
अपनी Info.plist अपडेट करें
दो कुंजियां जोड़ने के लिए, अपने ऐप्लिकेशन की Info.plist
फ़ाइल को अपडेट करें:
आपकेAd Manager app ID found in the Ad Manager UI and of the form
ca-app-pub-################~##########
की स्ट्रिंग वैल्यू के साथ एकGADApplicationIdentifier
कुंजी.Google के लिए
SKAdNetworkIdentifier
वैल्यू वाली एकSKAdNetworkItems
कुंजी (cstr6suwn9.skadnetwork
) और तीसरे पक्ष के उन खरीदारों को चुनें जिन्होंने Google को ये वैल्यू दी हैं.
स्निपेट पूरा करें
<key>GADApplicationIdentifier</key> <string>ca-app-pub-3940256099942544~1458002511</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>4pfyvq9l8r.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>5a6flpkh64.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>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>v4nxqhlyqp.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>wzmmz9fp6w.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>n6fk4nfna4.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>eh6m2bh4zr.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>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>ecpz2srf59.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>uw77j35x4d.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>pwa73g5rt2.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>mlmmfzh3r3.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>e5fvkxwrpn.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>8c4e2ghe7u.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>zq492l623r.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>3rd42ekr43.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>3qcr597p9d.skadnetwork</string> </dict> </array>
शुरू करने की प्रक्रिया को बेहतर तरीके से शुरू करने के लिए, ज़रूरी है कि आपके यील्ड ग्रुप को उन खास ऐप्लिकेशन के साथ जोड़ा जाए जिनमें उनका इस्तेमाल किया गया है. iOS को टारगेट करने वाले यील्ड ग्रुप कॉन्फ़िगरेशन, जो किसी खास ऐप्लिकेशन से जुड़े नहीं हैं, आपके खाते में मौजूद सभी iOS ऐप्लिकेशन पर भेज दिए जाएंगे. इससे इसे शुरू होने में ज़्यादा समय लग सकता है.
किसी असल ऐप्लिकेशन में, सैंपल ऐप्लिकेशन आईडी को अपने असलAd Manager ऐप्लिकेशन आईडी से बदलें. अगर Hello World ऐप्लिकेशन में SDK टूल को एक्सपेरिमेंट के तौर पर इस्तेमाल किया जा रहा है, तो इस सैंपल आईडी का इस्तेमाल किया जा सकता है.
Mobile Ads SDK शुरू करें
विज्ञापन लोड करने से पहले, GADMobileAds.sharedInstance
पर startWithCompletionHandler:
तरीके को कॉल करें. इससे SDK टूल शुरू होता है और प्रोसेस शुरू होने के बाद या 30 सेकंड के टाइम आउट के बाद, पूरा होने वाले हैंडलर को कॉल किया जाता है. ऐसा सिर्फ़ एक बार करना होता है, आम तौर पर ऐप्लिकेशन लॉन्च के समय. आपको जल्द से जल्द startWithCompletionHandler:
को कॉल करना चाहिए.
यहां एक उदाहरण दिया गया है, जिसमें AppDelegate
में startWithCompletionHandler:
तरीके को कॉल करने का तरीका बताया गया है:
AppDelegate का उदाहरण (उद्धरण)
Swift
import GoogleMobileAds
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GADMobileAds.sharedInstance().start(completionHandler: nil)
return true
}
}
SwiftUI
import GoogleMobileAds
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GADMobileAds.sharedInstance().start(completionHandler: nil)
return true
}
}
@main
struct YourApp: App {
// To handle app delegate callbacks in an app that uses the SwiftUI lifecycle,
// you must create an application delegate and attach it to your `App` struct
// using `UIApplicationDelegateAdaptor`.
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
NavigationView {
ContentView()
}
}
}
}
Objective-C
@import GoogleMobileAds;
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GADMobileAds.sharedInstance startWithCompletionHandler:nil];
return YES;
}
@end
कोई विज्ञापन फ़ॉर्मैट चुनें
मोबाइल विज्ञापन SDK टूल को अब इंपोर्ट करके, शुरू कर दिया गया है. अब इसमें विज्ञापन लागू किया जा सकता है. Ad Manager इसमें कई अलग-अलग विज्ञापन फ़ॉर्मैट हैं, ताकि आप अपने ऐप्लिकेशन के उपयोगकर्ता अनुभव के हिसाब से सबसे सही फ़ॉर्मैट चुन सकें.
SwiftUI डेवलपर के लिए, हमारी SwiftUI गाइड फ़ॉलो करें.
बैनर
बैनर विज्ञापन यूनिट, आयताकार विज्ञापन दिखाती हैं. ये विज्ञापन, ऐप्लिकेशन के लेआउट का कुछ हिस्सा घेरते हैं. वे एक तय समयसीमा के बाद अपने-आप रीफ़्रेश हो सकते हैं. इसका मतलब है कि उपयोगकर्ता नियमित अंतराल पर नया विज्ञापन देखते हैं, भले ही वे आपके ऐप्लिकेशन में एक ही स्क्रीन पर बने रहें. यह लागू करने का सबसे आसान विज्ञापन फ़ॉर्मैट है.
मध्यवर्ती
इंटरस्टीशियल विज्ञापन यूनिट आपके ऐप्लिकेशन में पूरे पेज के विज्ञापन दिखाती हैं. उन्हें अपने ऐप्लिकेशन के इंटरफ़ेस में सामान्य ब्रेक और ट्रांज़िशन पर रखें. जैसे, किसी गेमिंग ऐप्लिकेशन में लेवल पूरा करने के बाद.
अचानक दिखने वाले (इंटरस्टीशियल) विज्ञापन लागू करना
मूल भाषा वाला
नेटिव विज्ञापन ऐसे विज्ञापन होते हैं जिनमें आप अपने ऐप्लिकेशन में हेडलाइन और कॉल टू एक्शन जैसे एसेट को दिखाने के तरीके को पसंद के मुताबिक बना सकते हैं. विज्ञापन को खुद स्टाइल करके, आप सहज और बिना रुकावट वाले विज्ञापन प्रज़ेंटेशन बना सकते हैं. इससे उपयोगकर्ताओं को शानदार अनुभव मिलेगा.
Google Ad Manager नेटिव विज्ञापनों को लागू करने के दो तरीके देता है: नेटिव स्टाइल और कस्टम रेंडरिंग के ज़रिए स्टैंडर्ड नेटिव विज्ञापन.
नेटिव स्टाइल को इस तरह डिज़ाइन किया गया है कि नेटिव विज्ञापनों को आसानी से लागू किया जा सके. अगर आप इस फ़ॉर्मैट के लिए नए हैं, तो यह एक अच्छा विकल्प है. कस्टम रेंडरिंग को इस तरह डिज़ाइन किया गया है कि आपको प्रज़ेंटेशन बनाने की आज़ादी मिले.
नेटिव स्टाइल लागू करें नेटिव विज्ञापन (कस्टम रेंडरिंग) लागू करें
इनाम दिया गया
इनाम वाली विज्ञापन यूनिट की मदद से, उपयोगकर्ता गेम खेल सकते हैं, सर्वे में हिस्सा ले सकते हैं या इन-ऐप्लिकेशन इनाम जैसे कि सिक्के, खेलने के ज़्यादा मौके या पॉइंट पाने के लिए वीडियो देख सकते हैं. अलग-अलग विज्ञापन यूनिट के लिए, अलग-अलग इनाम सेट किए जा सकते हैं. साथ ही, उपयोगकर्ताओं को मिले इनामों की वैल्यू और आइटम भी तय किए जा सकते हैं.
इनाम वाले इंटरस्टीशियल विज्ञापन
इनाम वाला इंटरस्टीशियल विज्ञापन, नए तरह का फ़ायदा देने वाला विज्ञापन फ़ॉर्मैट है. इसकी मदद से, ऐप्लिकेशन में ट्रांज़िशन के दौरान अपने-आप दिखने वाले विज्ञापनों के लिए, कॉइन या खेलने के कुछ और मौके जैसे इनाम ऑफ़र किए जा सकते हैं.
इनाम वाले विज्ञापनों के उलट, उपयोगकर्ताओं को इनाम वाले इंटरस्टीशियल विज्ञापनों को देखने के लिए ऑप्ट-इन करना ज़रूरी नहीं होता.
इनाम वाले विज्ञापनों में ऑप्ट-इन करने के प्रॉम्प्ट के बजाय, इनाम वाले इंटरस्टीशियल विज्ञापनों को एक इंट्रो स्क्रीन की ज़रूरत होती है, जिसमें इनाम के बारे में बताया जाता है. साथ ही, अगर उपयोगकर्ता ऐसा करना चाहते हैं, तो उन्हें ऑप्ट-आउट करने का मौका मिलता है.
इनाम वाले इंटरस्टीशियल विज्ञापन लागू करना
ऐप्लिकेशन खोलने पर दिखने वाला विज्ञापन
ऐप्लिकेशन खोलने पर दिखने वाला विज्ञापन एक विज्ञापन फ़ॉर्मैट है. यह उपयोगकर्ताओं के आपके ऐप्लिकेशन को खोलने या उस पर वापस स्विच करने पर दिखता है. विज्ञापन, लोड होने वाली स्क्रीन को ओवरले करता है.