Google User Messaging Platform (UMP) SDK, निजता और मैसेज सेवा से जुड़ा एक टूल है. इससे आपको निजता के विकल्प मैनेज करने में मदद मिलती है. ज़्यादा जानकारी के लिए, निजता और मैसेज सेवा के बारे में जानकारी लेख पढ़ें. UMP SDK के साथ काम करने वाले IMA को Objective-C या Swift UMP के सैंपल ऐप्लिकेशन में देखा जा सकता है.
मैसेज टाइप बनाना
अपने Ad Manager खाते के निजता और मैसेज सेवा टैब में जाकर, उपयोगकर्ता मैसेज के उपलब्ध टाइप में से किसी एक का इस्तेमाल करके, उपयोगकर्ता मैसेज बनाएं. UMP SDK, आपके प्रोजेक्ट में सेट किए गए Interactive Media Ads ऐप्लिकेशन आईडी से बनाए गए निजता मैसेज को दिखाने की कोशिश करता है.
ज़्यादा जानकारी के लिए, निजता और मैसेज सेवा के बारे में जानकारी लेख पढ़ें.
एसडीके इंपोर्ट करना
UMP SDK, IMA SDK की डिपेंडेंसी के तौर पर शामिल नहीं है. इसलिए, आपको इसे खुद से जोड़ना होगा.
CocoaPods (पसंदीदा)
एसडीके को किसी iOS प्रोजेक्ट में इंपोर्ट करने का सबसे आसान तरीका, CocoaPods का इस्तेमाल करना है. अपने प्रोजेक्ट का Podfile खोलें और अपने ऐप्लिकेशन के टारगेट में यह लाइन जोड़ें:
pod 'GoogleUserMessagingPlatform'
इसके बाद, यह कमांड चलाएं:
pod install --repo-update
अगर आपने CocoaPods का इस्तेमाल पहले कभी नहीं किया है, तो CocoaPods का इस्तेमाल करना लेख पढ़ें. इसमें Podfile बनाने और इस्तेमाल करने के बारे में जानकारी दी गई है.
Swift Package Manager
UMP SDK, Swift Package Manager के साथ भी काम करता है. Swift पैकेज इंपोर्ट करने के लिए, यह तरीका अपनाएं.
Xcode में, UMP SDK Swift Package इंस्टॉल करें. इसके लिए, File > Add Packages... पर जाएं.
दिखने वाले प्रॉम्प्ट में, UMP SDK Swift Package GitHub रिपॉज़िटरी खोजें:
https://github.com/googleads/swift-package-manager-google-user-messaging-platform.git
UMP SDK Swift Package का वह वर्शन चुनें जिसका आपको इस्तेमाल करना है. नए प्रोजेक्ट के लिए, हमारा सुझाव है कि अगले मुख्य वर्शन तक का इस्तेमाल करें.
इसके बाद, Xcode आपके पैकेज की डिपेंडेंसी से जुड़ी समस्या को हल करता है और उन्हें बैकग्राउंड में डाउनलोड करता है. पैकेज डिपेंडेंसी जोड़ने के तरीके के बारे में ज़्यादा जानने के लिए, Apple का लेख पढ़ें.
ऐप्लिकेशन आईडी जोड़ना
ऐप्लिकेशन आईडी, Ad Manager यूज़र इंटरफ़ेस (यूआई) में देखा जा सकता है.
इस कोड स्निपेट का इस्तेमाल करके, अपने Info.plist
में आईडी जोड़ें:
<key>UMPApplicationIdentifier</key>
<string>ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy</string>
उपयोगकर्ता की सहमति से जुड़ी जानकारी पाना
आपको
requestConsentInfoUpdateWithParameters:completionHandler:
का इस्तेमाल करके, हर बार ऐप्लिकेशन लॉन्च करने पर उपयोगकर्ता की सहमति की जानकारी को अपडेट करने का अनुरोध करना चाहिए. इस अनुरोध में इन चीज़ों की जांच की जाती है:
- सहमति लेना ज़रूरी है या नहीं. उदाहरण के लिए, पहली बार सहमति लेनी हो या सहमति देने से जुड़ा पिछला फ़ैसला मान्य न रहा हो.
- निजता विकल्पों के एंट्री पॉइंट की ज़रूरत है या नहीं. निजता से जुड़े कुछ मैसेज के लिए, ऐप्लिकेशन को उपयोगकर्ताओं को यह अनुमति देनी होती है कि वे किसी भी समय निजता से जुड़े विकल्पों में बदलाव कर सकें.
Swift
// Requesting an update to consent information should be called on every app launch.
ConsentInformation.shared.requestConsentInfoUpdate(with: parameters) {
requestConsentError in
// ...
}
Objective-C
// Requesting an update to consent information should be called on every app launch.
[UMPConsentInformation.sharedInstance
requestConsentInfoUpdateWithParameters:parameters
completionHandler:^(NSError *_Nullable requestConsentError) {
// ...
}];
निजता से जुड़ा मैसेज दिखाने वाला फ़ॉर्म लोड करता है और उसे दिखाता है
सहमति की स्थिति के बारे में सबसे नया अपडेट मिलने के बाद,
loadAndPresentIfRequiredFromViewController:completionHandler:
को कॉल करें, ताकि उपयोगकर्ता की सहमति लेने के लिए ज़रूरी फ़ॉर्म लोड किए जा सकें. लोड होने के बाद, फ़ॉर्म तुरंत दिखने लगते हैं.
Swift
try await ConsentForm.loadAndPresentIfRequired(from: viewController)
Objective-C
[UMPConsentForm
loadAndPresentIfRequiredFromViewController:viewController
completionHandler:^(NSError *_Nullable loadAndPresentError) {
// Consent gathering process is complete.
}];
निजता के विकल्प
निजता से जुड़े कुछ मैसेज फ़ॉर्म, पब्लिशर के रेंडर किए गए निजता विकल्पों के एंट्री पॉइंट से दिखाए जाते हैं. इससे उपयोगकर्ता, किसी भी समय निजता विकल्पों को मैनेज कर पाते हैं. निजता विकल्पों के एंट्री पॉइंट पर, आपके उपयोगकर्ताओं को कौनसा मैसेज दिखता है, इस बारे में ज़्यादा जानने के लिए, उपयोगकर्ताओं के लिए उपलब्ध मैसेज टाइप देखें.
देखें कि निजता विकल्पों का एंट्री पॉइंट ज़रूरी है या नहीं
requestConsentInfoUpdateWithParameters:completionHandler:
को कॉल करने के बाद,
UMPConsentInformation.sharedInstance.privacyOptionsRequirementStatus
की जांच करें. इससे यह पता चलेगा कि आपके ऐप्लिकेशन के लिए, निजता के विकल्पों वाला एंट्री पॉइंट ज़रूरी है या नहीं. अगर एंट्री पॉइंट ज़रूरी है, तो अपने ऐप्लिकेशन में दिखने वाला और इंटरैक्ट किया जा सकने वाला यूज़र इंटरफ़ेस (यूआई) एलिमेंट जोड़ें. इससे निजता के विकल्पों वाला फ़ॉर्म दिखेगा. अगर निजता एंट्री पॉइंट की ज़रूरत नहीं है, तो अपने यूज़र इंटरफ़ेस (यूआई) एलिमेंट को इस तरह कॉन्फ़िगर करें कि वह दिखे नहीं और उसके साथ इंटरैक्ट न किया जा सके.
Swift
var isPrivacyOptionsRequired: Bool {
return ConsentInformation.shared.privacyOptionsRequirementStatus == .required
}
Objective-C
- (BOOL)isPrivacyOptionsRequired {
return UMPConsentInformation.sharedInstance.privacyOptionsRequirementStatus ==
UMPPrivacyOptionsRequirementStatusRequired;
}
- (void)gatherConsentFromConsentPresentationViewController:(UIViewController *)viewController
consentGatheringComplete:
(void (^)(NSError *_Nullable))consentGatheringComplete {
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
// Set tag for under age of consent. Use NO constant to indicate that the user is not under age.
parameters.tagForUnderAgeOfConsent = NO;
UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
// Uncomment the following line to simulate a consent request from users in the
// European Economic Area (EEA) for testing purposes.
// debugSettings.geography = UMPDebugGeographyEEA;
parameters.debugSettings = debugSettings;
// Requesting an update to consent information should be called on every app launch.
[UMPConsentInformation.sharedInstance
requestConsentInfoUpdateWithParameters:parameters
completionHandler:^(NSError *_Nullable requestConsentError) {
// ...
}];
}
- (void)loadAndPresentIfRequiredFromViewController:(UIViewController *)viewController
completionHandler:(void (^)(NSError *_Nullable))completionHandler {
[UMPConsentForm
loadAndPresentIfRequiredFromViewController:viewController
completionHandler:^(NSError *_Nullable loadAndPresentError) {
// Consent gathering process is complete.
}];
}
- (void)presentPrivacyOptionsFormFromViewController:(UIViewController *)viewController
completionHandler:
(void (^)(NSError *_Nullable))completionHandler {
[UMPConsentForm presentPrivacyOptionsFormFromViewController:viewController
completionHandler:completionHandler];
}
@end
निजता विकल्पों से जुड़ी ज़रूरी शर्तों के स्टेटस की पूरी सूची देखने के लिए,
UMPPrivacyOptionsRequirementStatus
पर जाएं.
निजता के विकल्पों वाला फ़ॉर्म दिखाना
जब उपयोगकर्ता आपके एलिमेंट से इंटरैक्ट करे, तब निजता के विकल्पों वाला फ़ॉर्म दिखाएं:
Swift
ConsentForm.presentPrivacyOptionsForm(
from: viewController, completionHandler: completionHandler)
Objective-C
[UMPConsentForm presentPrivacyOptionsFormFromViewController:viewController
completionHandler:completionHandler];
उपयोगकर्ता की सहमति के साथ विज्ञापनों का अनुरोध करना
विज्ञापनों का अनुरोध करने से पहले,
UMPConsentInformation.sharedInstance.canRequestAds
का इस्तेमाल करके यह देखें कि आपने उपयोगकर्ता से सहमति ली है या नहीं:
Swift
ConsentInformation.shared.canRequestAds
Objective-C
UMPConsentInformation.sharedInstance.canRequestAds;
यहां दी गई जगहों पर जाकर देखें कि सहमति लेते समय, विज्ञापन दिखाने का अनुरोध किया जा सकता है या नहीं:
- जब UMP SDK, मौजूदा सेशन में सहमति ले लेता है.
requestConsentInfoUpdateWithParameters:completionHandler:
को कॉल करने के तुरंत बाद. ऐसा हो सकता है कि UMP SDK टूल ने पिछले ऐप्लिकेशन सेशन में सहमति ले ली हो.
अगर सहमति लेने की प्रोसेस के दौरान कोई गड़बड़ी होती है, तो देखें कि क्या विज्ञापन का अनुरोध किया जा सकता है. UMP SDK, ऐप्लिकेशन के पिछले सेशन से सहमति की स्थिति का इस्तेमाल करता है.
विज्ञापन के अनुरोध से जुड़े काम को बार-बार करने से रोकना
सहमति मिलने के बाद और
requestConsentInfoUpdateWithParameters:completionHandler:
को कॉल करने के बाद,
UMPConsentInformation.sharedInstance.canRequestAds
की जांच करते समय, यह पक्का करें कि आपका लॉजिक, विज्ञापन के ऐसे फ़ालतू अनुरोधों को रोकता हो जिनकी वजह से दोनों जांचों में true
मिल सकता है. उदाहरण के लिए, बूलियन वैरिएबल के साथ.
टेस्ट करना
अगर आपको डेवलपमेंट के दौरान अपने ऐप्लिकेशन में इंटिग्रेशन की जांच करनी है, तो प्रोग्राम के हिसाब से अपने टेस्ट डिवाइस को रजिस्टर करने के लिए, यह तरीका अपनाएं. अपने ऐप्लिकेशन को रिलीज़ करने से पहले, टेस्ट डिवाइस के आईडी सेट करने वाले कोड को हटाना न भूलें.
requestConsentInfoUpdateWithParameters:completionHandler:
पर कॉल करें.नीचे दिए गए उदाहरण की तरह दिखने वाले मैसेज के लिए, लॉग आउटपुट देखें. इसमें आपका डिवाइस आईडी और उसे टेस्ट डिवाइस के तौर पर जोड़ने का तरीका बताया गया है:
<UMP SDK>To enable debug mode for this device, set: UMPDebugSettings.testDeviceIdentifiers = @[2077ef9a63d2b398840261c8221a0c9b]
अपने टेस्ट डिवाइस का आईडी क्लिपबोर्ड पर कॉपी करें.
अपने कोड में बदलाव करके,
UMPDebugSettings().testDeviceIdentifiers
को कॉल करें और अपने टेस्ट डिवाइस आईडी की सूची पास करें.Swift
let parameters = RequestParameters() let debugSettings = DebugSettings() debugSettings.testDeviceIdentifiers = ["TEST-DEVICE-HASHED-ID"] parameters.debugSettings = debugSettings // Include the UMPRequestParameters in your consent request. ConsentInformation.shared.requestConsentInfoUpdate( with: parameters, completionHandler: { error in // ... })
Objective-C
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init]; UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init]; debugSettings.testDeviceIdentifiers = @[ @"TEST-DEVICE-HASHED-ID" ]; parameters.debugSettings = debugSettings; // Include the UMPRequestParameters in your consent request. [UMPConsentInformation.sharedInstance requestConsentInfoUpdateWithParameters:parameters completionHandler:^(NSError *_Nullable error){ // ... }];
किसी देश या इलाके को टारगेट करना
UMP SDK टूल, UMPDebugGeography का इस्तेमाल करके, आपके ऐप्लिकेशन के व्यवहार को इस तरह से टेस्ट करने का तरीका उपलब्ध कराता है जैसे कि डिवाइस अलग-अलग क्षेत्रों में मौजूद हो. जैसे, ईईए या यूके. ध्यान दें कि डीबग सेटिंग सिर्फ़ टेस्ट डिवाइसों पर काम करती हैं.
Swift
let parameters = RequestParameters()
let debugSettings = DebugSettings()
debugSettings.testDeviceIdentifiers = ["TEST-DEVICE-HASHED-ID"]
debugSettings.geography = .EEA
parameters.debugSettings = debugSettings
// Include the UMPRequestParameters in your consent request.
ConsentInformation.shared.requestConsentInfoUpdate(
with: parameters,
completionHandler: { error in
// ...
})
Objective-C
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
debugSettings.testDeviceIdentifiers = @[ @"TEST-DEVICE-HASHED-ID" ];
debugSettings.geography = UMPDebugGeographyEEA;
parameters.debugSettings = debugSettings;
// Include the UMPRequestParameters in your consent request.
[UMPConsentInformation.sharedInstance
requestConsentInfoUpdateWithParameters:parameters
completionHandler:^(NSError *_Nullable error){
// ...
}];
सहमति की स्थिति रीसेट करना
UMP SDK टूल का इस्तेमाल करके अपने ऐप्लिकेशन की जांच करते समय, आपको SDK टूल की स्थिति रीसेट करने में मदद मिल सकती है. इससे, उपयोगकर्ता के लिए ऐप्लिकेशन को पहली बार इंस्टॉल करने का अनुभव सिम्युलेट किया जा सकता है.
एसडीके, ऐसा करने के लिए reset
तरीका उपलब्ध कराता है.
Swift
ConsentInformation.shared.reset()
Objective-C
[UMPConsentInformation.sharedInstance reset];
GitHub पर मौजूद उदाहरण
इस पेज पर दिए गए UMP SDK टूल के इंटिग्रेशन का पूरा उदाहरण, Swift UmpExample और Objective-C UmpExample में देखें.