Google Mobile Ads SDK को किसी ऐप्लिकेशन में इंटिग्रेट करना, आपके लिए सबसे पहले विज्ञापन दिखाकर और कमाई करने में मदद करता है. SDK टूल को इंटिग्रेट करने के बाद, ये काम किए जा सकते हैं एक या उससे ज़्यादा यूआरएल के लिए का इस्तेमाल किया जा सकता है.
ज़रूरी शर्तें
- Xcode 15.3 या इसके बाद के वर्शन का इस्तेमाल करना
- iOS 12.0 या इसके बाद के वर्शन को टारगेट करें
मोबाइल विज्ञापन SDK टूल इंपोर्ट करें
Google Mobile Ads SDK को इंपोर्ट करने के लिए, इनमें से किसी एक तरीके का इस्तेमाल करें.
CocoaPods (पसंदीदा)
किसी iOS प्रोजेक्ट में SDK टूल को इंपोर्ट करने का सबसे आसान तरीका है, CocoaPods. कोई भी शामिल हो सकता है अपने प्रोजेक्ट की Podfile पर जाएं और इस लाइन को अपने ऐप्लिकेशन के टारगेट में जोड़ें:
pod 'Google-Mobile-Ads-SDK'
फिर कमांड लाइन से चलाएं:
pod install --repo-update
अगर आपने CocoaPods का पहले कभी इस्तेमाल नहीं किया है, तो जानकारी के लिए आधिकारिक दस्तावेज़ पॉडफ़ाइल बनाने और उन्हें इस्तेमाल करने का तरीका जानें.
Swift पैकेज मैनेजर
Google Mobile Ads SDK, Swift Package के साथ काम करता है मैनेजर का वर्शन 9.0.0. इन्हें फ़ॉलो करें 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 का लेख पढ़ें.
मैन्युअल डाउनलोड
Google Mobile Ads SDK डाउनलोड करें और
Embed & Sign
अपने Xcode प्रोजेक्ट में ये फ़्रेमवर्क देखें:GoogleMobileAds.xcframework
UserMessagingPlatform.xcframework
अपने प्रोजेक्ट के अन्य लिंकर फ़्लैग में
-ObjC
लिंकर फ़्लैग जोड़ें बिल्ड सेटिंग:
अपनी Info.plist अपडेट करें
दो कुंजियां जोड़ने के लिए, अपने ऐप्लिकेशन की Info.plist
फ़ाइल को अपडेट करें:
आपकी स्ट्रिंग वैल्यू के साथ
GADApplicationIdentifier
कुंजी Ad Manager app ID found in the Ad Manager UI and of the formca-app-pub-################~##########
.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 शुरू करें
विज्ञापन लोड करने से पहले, startWithCompletionHandler:
पद्धति को
GADMobileAds.sharedInstance
,
जो SDK टूल को शुरू करता है और एक बार पूरा होने वाले हैंडलर को कॉल करता है
शुरू हो गया है (या 30 सेकंड के टाइम आउट के बाद). इसे सिर्फ़
एक बार किया जाना चाहिए, खास तौर पर ऐप्लिकेशन लॉन्च के समय. आपको startWithCompletionHandler:
को कॉल करना चाहिए
जल्द से जल्द.
यहां startWithCompletionHandler:
तरीके को कॉल करने का तरीका बताया गया है
आपका AppDelegate
:
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 में नेटिव विज्ञापनों को लागू करने के दो तरीके हैं: नेटिव स्टाइल और स्टैंडर्ड नेटिव विज्ञापनों को कॉपी कर सकते हैं.
नेटिव स्टाइल को इस तरह डिज़ाइन किया गया है कि नेटिव विज्ञापनों को आसानी से लागू किया जा सके. और अगर आप इस फ़ॉर्मैट के लिए नए हैं, तो यह एक बेहतरीन विकल्प है. कस्टम रेंडरिंग को इस तरह डिज़ाइन किया गया है कि आपको प्रज़ेंटेशन बनाने की आज़ादी मिले.
नेटिव स्टाइल लागू करना नेटिव विज्ञापन (पसंद के मुताबिक रेंडरिंग) लागू करना
इनाम दिया गया
इनाम वाली विज्ञापन यूनिट की मदद से, उपयोगकर्ता गेम खेल सकते हैं, सर्वे में हिस्सा ले सकते हैं या वीडियो देख सकते हैं ऐप में इनाम, जैसे कि कॉइन, खेलने के कुछ और मौके या पॉइंट हासिल कर सकते हैं. आप सेट कर सकते हैं अलग-अलग विज्ञापन यूनिट के लिए अलग-अलग इनाम होते हैं. साथ ही, इनाम की वैल्यू और जो उपयोगकर्ता को मिले हैं.
इनाम वाले इंटरस्टीशियल विज्ञापन
इनाम वाला इंटरस्टीशियल विज्ञापन, नए तरह का फ़ायदा देने वाला विज्ञापन फ़ॉर्मैट है. इसकी मदद से, अपने-आप दिखने वाले विज्ञापनों के लिए, कॉइन या खेलने के कुछ और मौके जैसे इनाम दें ऐप्लिकेशन के नैचुरल ट्रांज़िशन के दौरान.
इनाम वाले विज्ञापनों के उलट, उपयोगकर्ताओं को इनाम वाले विज्ञापन देखने के लिए ऑप्ट इन करना ज़रूरी नहीं होता पेज पर अचानक दिखने वाले विज्ञापन.
इनाम वाले विज्ञापनों में ऑप्ट-इन करने के प्रॉम्प्ट के बजाय, इनाम वाले इंटरस्टीशियल विज्ञापनों को इस्तेमाल करने के लिए परिचय स्क्रीन, इनाम के बारे में बताती है. साथ ही, उपयोगकर्ताओं को ऑप्ट आउट करने का मौका देती है, अगर वे ऐसा करना चाहते हैं.
इनाम वाले इंटरस्टीशियल विज्ञापन लागू करना
ऐप्लिकेशन खोलने पर दिखने वाला विज्ञापन
ऐप्लिकेशन खोलने पर दिखने वाला विज्ञापन एक ऐसा विज्ञापन फ़ॉर्मैट है जो तब दिखता है, जब उपयोगकर्ता आपके ऐप्लिकेशन को खोलते हैं या उस पर वापस स्विच करते हैं है. विज्ञापन, लोड होने वाली स्क्रीन को ओवरले कर लेता है.