UMP SDK टूल सेट अप करना

प्लैटफ़ॉर्म चुनें: Android iOS Unity Flutter Android (लेगसी)

Google User Messaging Platform (UMP) SDK, निजता और मैसेज सेवा से जुड़ा टूल है. इसकी मदद से, निजता के विकल्पों को मैनेज किया जा सकता है. ज़्यादा जानकारी के लिए, निजता और मैसेज सेवा के बारे में जानकारी देखें.

ज़रूरी शर्तें

  • Android एपीआई लेवल 21 या इसके बाद का वर्शन

मैसेज का टाइप बनाना

अपने AdMob खाते के निजता और मैसेज सेवा टैब में जाकर, उपयोगकर्ता मैसेज के उपलब्ध टाइप में से किसी एक का इस्तेमाल करके उपयोगकर्ता मैसेज बनाएं. UMP SDK, आपके प्रोजेक्ट में सेट किए गए AdMob ऐप्लिकेशन आईडी से बनाए गए निजता मैसेज को दिखाने की कोशिश करता है.

ज़्यादा जानकारी के लिए, निजता और मैसेज सेवा के बारे में जानकारी देखें.

Gradle की मदद से इंस्टॉल करना

अपने मॉड्यूल की ऐप्लिकेशन-लेवल Gradle फ़ाइल में, Google User Messaging Platform SDK (UMP SDK) के लिए डिपेंडेंसी जोड़ें. आम तौर पर, यह फ़ाइल app/build.gradle होती है:

dependencies {
  implementation("com.google.android.ump:user-messaging-platform:4.0.0")
}

अपने ऐप्लिकेशन की build.gradle में बदलाव करने के बाद, अपने प्रोजेक्ट को Gradle फ़ाइलों के साथ सिंक करना न भूलें.

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

AdMob के यूज़र इंटरफ़ेस (यूआई) में, आपको अपना ऐप्लिकेशन आईडी मिल सकता है. इस कोड स्निपेट का इस्तेमाल करके, आईडी को अपने AndroidManifest.xml में जोड़ें:

<manifest>
  <application>
    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
  </application>
</manifest>

उपयोगकर्ता की सहमति की जानकारी पाने के लिए, यह तरीका अपनाएं:

ConsentInformation का कोई इंस्टेंस तय करें:

Java

private final ConsentInformation consentInformation;

Kotlin

private lateinit var consentInformation: ConsentInformation

ConsentInformation इंस्टेंस को शुरू करें:

Java

consentInformation = UserMessagingPlatform.getConsentInformation(context);

Kotlin

consentInformation = UserMessagingPlatform.getConsentInformation(context)

आपको requestConsentInfoUpdate() का इस्तेमाल करके, हर बार ऐप्लिकेशन लॉन्च होने पर उपयोगकर्ता की सहमति की जानकारी को अपडेट करने का अनुरोध करना चाहिए. इस अनुरोध से इन चीज़ों की जांच की जाती है:

  • क्या सहमति ज़रूरी है. उदाहरण के लिए, पहली बार सहमति लेना ज़रूरी है या सहमति देने के पिछले फ़ैसले की समयसीमा खत्म हो गई है.
  • क्या निजता विकल्पों का एंट्री पॉइंट ज़रूरी है. निजता से जुड़े कुछ मैसेज के लिए, ऐप्लिकेशन को उपयोगकर्ताओं को यह अनुमति देनी होगी कि वे किसी भी समय अपनी निजता सेटिंग में बदलाव कर सकें.

Java


// Requesting an update to consent information should be called on every app launch.
consentInformation.requestConsentInfoUpdate(
    activity,
    params,
    () -> // Called when consent information is successfully updated.
    requestConsentError -> // Called when there's an error updating consent information.

Kotlin


// Requesting an update to consent information should be called on every app launch.
consentInformation.requestConsentInfoUpdate(
  activity,
  params,
  {
    // Called when consent information is successfully updated.
  },
  { requestConsentError ->
    // Called when there's an error updating consent information.
  },
)

निजता से जुड़े मैसेज का फ़ॉर्म लोड करना और दिखाना

सहमति की सबसे अप-टू-डेट स्थिति मिलने के बाद, उपयोगकर्ता की सहमति लेने के लिए ज़रूरी फ़ॉर्म लोड करने के लिए, loadAndShowConsentFormIfRequired() को कॉल करें. लोड होने के बाद, फ़ॉर्म तुरंत दिखते हैं.

Java


UserMessagingPlatform.loadAndShowConsentFormIfRequired(
    activity,
    formError -> {
      // Consent gathering process is complete.
    });

Kotlin


UserMessagingPlatform.loadAndShowConsentFormIfRequired(activity) { formError ->
  // Consent gathering process is complete.
}

निजता के विकल्प

निजता से जुड़े कुछ मैसेज, पब्लिशर की ओर से रेंडर किए गए निजता विकल्पों के एंट्री पॉइंट से दिखाए जाते हैं. इससे उपयोगकर्ता, किसी भी समय अपने निजता विकल्पों को मैनेज कर सकते हैं. निजता विकल्पों के एंट्री पॉइंट पर, आपके उपयोगकर्ताओं को कौनसा मैसेज दिखता है, इस बारे में ज़्यादा जानने के लिए, उपयोगकर्ताओं के लिए उपलब्ध मैसेज टाइप देखें.

यह देखना कि निजता के विकल्पों वाला एंट्री पॉइंट ज़रूरी है या नहीं

requestConsentInfoUpdate() को कॉल करने के बाद, getPrivacyOptionsRequirementStatus() की जांच करें. इससे यह पता चलेगा कि आपके ऐप्लिकेशन के लिए, निजता के विकल्पों वाला एंट्री पॉइंट ज़रूरी है या नहीं. अगर एंट्री पॉइंट ज़रूरी है, तो अपने ऐप्लिकेशन में यूज़र इंटरफ़ेस (यूआई) का ऐसा एलिमेंट जोड़ें जो दिखे और जिससे इंटरैक्ट किया जा सके. यह एलिमेंट, निजता के विकल्पों वाला फ़ॉर्म दिखाता है. अगर निजता एंट्री पॉइंट की ज़रूरत नहीं है, तो अपने यूज़र इंटरफ़ेस (यूआई) एलिमेंट को इस तरह कॉन्फ़िगर करें कि वह न दिखे और उससे इंटरैक्ट न किया जा सके.

Java


/** Helper variable to determine if the privacy options form is required. */
public boolean isPrivacyOptionsRequired() {
  return consentInformation.getPrivacyOptionsRequirementStatus()
      == PrivacyOptionsRequirementStatus.REQUIRED;
}

Kotlin


/** Helper variable to determine if the privacy options form is required. */
val isPrivacyOptionsRequired: Boolean
  get() =
    consentInformation.privacyOptionsRequirementStatus ==
      ConsentInformation.PrivacyOptionsRequirementStatus.REQUIRED

निजता विकल्पों की ज़रूरी शर्तों के स्टेटस की पूरी सूची देखने के लिए, ConsentInformation.PrivacyOptionsRequirementStatus पर जाएं.

निजता विकल्पों का फ़ॉर्म दिखाना

जब उपयोगकर्ता आपके एलिमेंट से इंटरैक्ट करे, तो निजता के विकल्पों वाला फ़ॉर्म दिखाएं:

Java


UserMessagingPlatform.showPrivacyOptionsForm(activity, onConsentFormDismissedListener);

Kotlin


UserMessagingPlatform.showPrivacyOptionsForm(activity, onConsentFormDismissedListener)

उपयोगकर्ता की सहमति से विज्ञापन दिखाने का अनुरोध करना

विज्ञापनों का अनुरोध करने से पहले, canRequestAds() का इस्तेमाल करके देखें कि आपने उपयोगकर्ता से सहमति ली है या नहीं:

Java

consentInformation.canRequestAds();

Kotlin

consentInformation.canRequestAds()

सहमति इकट्ठा करते समय, विज्ञापनों का अनुरोध किया जा सकता है या नहीं, यह देखने के लिए यहां दी गई जगहों पर जाएं:

  • जब UMP SDK, मौजूदा सेशन में सहमति इकट्ठा कर लेता है.
  • requestConsentInfoUpdate() को कॉल करने के तुरंत बाद. ऐसा हो सकता है कि UMP SDK ने पिछले ऐप्लिकेशन सेशन में सहमति ले ली हो.

अगर सहमति लेने की प्रोसेस के दौरान कोई गड़बड़ी होती है, तो देखें कि क्या विज्ञापनों के लिए अनुरोध किया जा सकता है. UMP SDK, ऐप्लिकेशन के पिछले सेशन में मिली सहमति की स्थिति का इस्तेमाल करता है.

विज्ञापन दिखाने के लिए बार-बार अनुरोध करने से बचें

सहमति लेने और requestConsentInfoUpdate() को कॉल करने के बाद, canRequestAds() की जांच करते समय पक्का करें कि आपका लॉजिक, विज्ञापन दिखाने के ऐसे अनुरोधों को रोकता हो जिनकी ज़रूरत नहीं है. ऐसा न होने पर, दोनों जांचों के नतीजे के तौर पर true मिल सकता है. उदाहरण के लिए, बूलियन वैरिएबल के साथ.

टेस्ट करना

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

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

    Use new ConsentDebugSettings.Builder().addTestDeviceHashedId("33BE2250B43518CCDA7DE426D04EE231") to set this as a debug device.
    
  3. अपने टेस्ट डिवाइस आईडी को क्लिपबोर्ड पर कॉपी करें.

  4. ConsentDebugSettings.Builder().TestDeviceHashedIds को कॉल करने के लिए, अपने कोड में बदलाव करें और टेस्ट डिवाइस आईडी की सूची पास करें.

    Java

    ConsentDebugSettings debugSettings = new ConsentDebugSettings.Builder(this)
        .addTestDeviceHashedId("TEST-DEVICE-HASHED-ID")
        .build();
    
    ConsentRequestParameters params = new ConsentRequestParameters
        .Builder()
        .setConsentDebugSettings(debugSettings)
        .build();
    
    consentInformation = UserMessagingPlatform.getConsentInformation(this);
    // Include the ConsentRequestParameters in your consent request.
    consentInformation.requestConsentInfoUpdate(
        this,
        params,
        // ...
    );
    

    Kotlin

    val debugSettings = ConsentDebugSettings.Builder(this)
        .addTestDeviceHashedId("TEST-DEVICE-HASHED-ID")
        .build()
    
    val params = ConsentRequestParameters
        .Builder()
        .setConsentDebugSettings(debugSettings)
        .build()
    
    consentInformation = UserMessagingPlatform.getConsentInformation(this)
    // Include the ConsentRequestParameters in your consent request.
    consentInformation.requestConsentInfoUpdate(
        this,
        params,
        // ...
    )
    

किसी देश या इलाके को ज़बरदस्ती लागू करना

UMP SDK, आपके ऐप्लिकेशन के व्यवहार की जांच करने का एक तरीका उपलब्ध कराता है. इससे यह पता चलता है कि आपका ऐप्लिकेशन, यूरोपियन इकनॉमिक एरिया (ईईए), यूनाइटेड किंगडम (यूके), और स्विट्ज़रलैंड जैसे अलग-अलग इलाकों में मौजूद डिवाइसों पर कैसा काम करेगा. इसके लिए, setDebugGeography() का इस्तेमाल किया जाता है. ध्यान दें कि डीबग सेटिंग सिर्फ़ टेस्ट डिवाइसों पर काम करती हैं.

Java

ConsentDebugSettings debugSettings = new ConsentDebugSettings.Builder(this)
    .setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA)
    .addTestDeviceHashedId("TEST-DEVICE-HASHED-ID")
    .build();

ConsentRequestParameters params = new ConsentRequestParameters
    .Builder()
    .setConsentDebugSettings(debugSettings)
    .build();

consentInformation = UserMessagingPlatform.getConsentInformation(this);
// Include the ConsentRequestParameters in your consent request.
consentInformation.requestConsentInfoUpdate(
    this,
    params,
    ...
);

Kotlin

val debugSettings = ConsentDebugSettings.Builder(this)
    .setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA)
    .addTestDeviceHashedId("TEST-DEVICE-HASHED-ID")
    .build()

val params = ConsentRequestParameters
    .Builder()
    .setConsentDebugSettings(debugSettings)
    .build()

consentInformation = UserMessagingPlatform.getConsentInformation(this)
// Include the ConsentRequestParameters in your consent request.
consentInformation.requestConsentInfoUpdate(
    this,
    params,
    ...
)

UMP SDK की मदद से अपने ऐप्लिकेशन की जांच करते समय, आपको SDK की स्थिति को रीसेट करना मददगार लग सकता है. इससे, उपयोगकर्ता के पहली बार ऐप्लिकेशन इंस्टॉल करने के अनुभव को सिम्युलेट किया जा सकता है. एसडीके, ऐसा करने के लिए reset() तरीका उपलब्ध कराता है.

Java

consentInformation.reset();

Kotlin

consentInformation.reset()

GitHub पर उदाहरण

इस पेज पर, UMP SDK टूल के इंटिग्रेशन का पूरा उदाहरण देखें. यह उदाहरण, Java BannerExample और Kotlin BannerExample में दिया गया है.