शुरू करना

प्लैटफ़ॉर्म चुनें: Android iOS

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 का इस्तेमाल पहले कभी नहीं किया है, तो Podfile बनाने और इस्तेमाल करने के बारे में जानने के लिए, CocoaPods का इस्तेमाल करना लेख पढ़ें.

Swift Package Manager

UMP SDK टूल, Swift Package Manager के साथ भी काम करता है. Swift पैकेज इंपोर्ट करने के लिए, यह तरीका अपनाएं.

  1. Xcode में, फ़ाइल > पैकेज जोड़ें... पर जाकर, UMP SDK टूल का Swift पैकेज इंस्टॉल करें.

  2. दिखने वाले प्रॉम्प्ट में, UMP SDK टूल के Swift पैकेज के GitHub रिपॉज़िटरी को खोजें:

    https://github.com/googleads/swift-package-manager-google-user-messaging-platform.git
    
  3. UMP SDK टूल के Swift पैकेज का वह वर्शन चुनें जिसका आपको इस्तेमाल करना है. नए प्रोजेक्ट के लिए, हमारा सुझाव है कि अगले बड़े वर्शन तक का इस्तेमाल करें.

इसके बाद, Xcode आपके पैकेज की डिपेंडेंसी से जुड़ी समस्या को हल करेगा और उन्हें बैकग्राउंड में डाउनलोड करेगा. पैकेज की डिपेंडेंसी जोड़ने के बारे में ज़्यादा जानने के लिए, Apple's लेख पढ़ें.

ऐप्लिकेशन आईडी जोड़ना

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 दिखे. उदाहरण के लिए, बूलियन वैरिएबल का इस्तेमाल करें.

टेस्ट करना

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

  1. requestConsentInfoUpdateWithParameters:completionHandler: को कॉल करें.
  2. लॉग आउटपुट में, इस उदाहरण की तरह कोई मैसेज देखें. इसमें, आपका डिवाइस आईडी और उसे टेस्ट डिवाइस के तौर पर जोड़ने का तरीका दिखाया गया है:

    <UMP SDK>To enable debug mode for this device, set: UMPDebugSettings.testDeviceIdentifiers = @[2077ef9a63d2b398840261c8221a0c9b]
    
  3. अपने टेस्ट डिवाइस का आईडी, क्लिपबोर्ड पर कॉपी करें.

  4. अपने कोड में बदलाव करें ताकि आप 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 टूल की स्थिति रीसेट करना मददगार साबित हो सकता है. इससे, उपयोगकर्ता के पहले इंस्टॉल करने के अनुभव को सिम्युलेट किया जा सकता है. इसके लिए, SDK टूल में reset तरीका उपलब्ध है.

Swift

ConsentInformation.shared.reset()

Objective-C

[UMPConsentInformation.sharedInstance reset];

GitHub पर मौजूद उदाहरण

इस पेज पर, UMP SDK टूल के इंटिग्रेशन का पूरा उदाहरण देखें. इसके लिए, Swift UmpExample और Objective-C UmpExample पर जाएं.