Google User Messaging Platform (UMP) SDK टूल, निजता और मैसेज सेवा से जुड़ा एक टूल है. इसकी मदद से, निजता से जुड़े विकल्पों को मैनेज किया जा सकता है. ज़्यादा जानकारी के लिए, निजता और मैसेज सेवा के बारे में लेख पढ़ें. UMP सैंपल ऐप्लिकेशन में, UMP SDK टूल के साथ काम करने वाला IMA लागू करने का तरीका देखा जा सकता है.
ज़रूरी शर्तें
- Android का एपीआई लेवल 21 या इसके बाद का वर्शन
मैसेज टाइप बनाना
Ad Manager खाते के निजता और मैसेज सेवा टैब में, उपयोगकर्ता मैसेज के उपलब्ध टाइप में से किसी एक का इस्तेमाल करके, उपयोगकर्ता मैसेज बनाएं. UMP SDK टूल, आपके प्रोजेक्ट में सेट किए गए इंटरैक्टिव मीडिया विज्ञापन ऐप्लिकेशन आईडी से बनाया गया निजता मैसेज दिखाने की कोशिश करता है.
ज़्यादा जानकारी के लिए, निजता और मैसेज सेवा के बारे में लेख पढ़ें.
Gradle की मदद से इंस्टॉल करना
अपने मॉड्यूल की ऐप्लिकेशन-लेवल वाली
Gradle फ़ाइल में, Google User Messaging Platform SDK टूल के लिए डिपेंडेंसी जोड़ें. आम तौर पर, यह फ़ाइल app/build.gradle होती है:
dependencies {
implementation("com.google.android.ump:user-messaging-platform:4.0.0")
}
अपने ऐप्लिकेशन की build.gradle में बदलाव करने के बाद, पक्का करें कि आपने अपने प्रोजेक्ट को Gradle फ़ाइलों के साथ सिंक किया हो.
ऐप्लिकेशन आईडी जोड़ना
Ad Manager के यूज़र इंटरफ़ेस (यूआई) में, अपना ऐप्लिकेशन आईडी देखा जा सकता है.
नीचे दिए गए कोड स्निपेट की मदद से, अपने
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 val 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 is complete.
}
निजता के विकल्प
निजता मैसेज वाले कुछ फ़ॉर्म, पब्लिशर के रेंडर किए गए निजता विकल्पों के एंट्री पॉइंट से दिखते हैं. इससे, उपयोगकर्ता किसी भी समय, निजता के विकल्प मैनेज कर सकते हैं. निजता विकल्पों के एंट्री पॉइंट पर, आपके उपयोगकर्ताओं को कौनसा मैसेज दिखता है, यह जानने के लिए, उपलब्ध उपयोगकर्ता मैसेज के टाइप देखें.
यह देखना कि निजता विकल्पों का एंट्री पॉइंट ज़रूरी है या नहीं
requestConsentInfoUpdate() को कॉल करने के बाद,
getPrivacyOptionsRequirementStatus() की जांच करें. इससे यह पता चलेगा कि आपके ऐप्लिकेशन के लिए, निजता विकल्पों का एंट्री पॉइंट ज़रूरी है या नहीं. अगर एंट्री पॉइंट ज़रूरी है, तो अपने ऐप्लिकेशन में दिखने वाला और इंटरैक्ट किया जा सकने वाला यूज़र इंटरफ़ेस (यूआई) एलिमेंट जोड़ें. इससे, निजता विकल्पों वाला फ़ॉर्म दिखेगा. अगर निजता एंट्री पॉइंट ज़रूरी नहीं है, तो अपने यूज़र इंटरफ़ेस (यूआई) एलिमेंट को इस तरह कॉन्फ़िगर करें कि वह दिखे नहीं और उससे इंटरैक्ट न किया जा सके.
Java
/** Helper function to determine if a privacy options entry point 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 दिखे. उदाहरण के लिए, बूलियन वैरिएबल का इस्तेमाल करें.
टेस्ट करना
अगर आपको डेवलपमेंट के दौरान, अपने ऐप्लिकेशन में इंटिग्रेशन की जांच करनी है, तो अपने टेस्ट डिवाइस को प्रोग्राम के ज़रिए रजिस्टर करने के लिए, यह तरीका अपनाएं. अपना ऐप्लिकेशन रिलीज़ करने से पहले, पक्का करें कि आपने टेस्ट डिवाइस के आईडी सेट करने वाला कोड हटा दिया हो.
requestConsentInfoUpdate()को कॉल करें.लॉग आउटपुट में, इस उदाहरण की तरह कोई मैसेज देखें. इसमें, आपका डिवाइस आईडी और उसे टेस्ट डिवाइस के तौर पर जोड़ने का तरीका दिखाया गया है:
Use new ConsentDebugSettings.Builder().addTestDeviceHashedId("33BE2250B43518CCDA7DE426D04EE231") to set this as a debug device.अपने टेस्ट डिवाइस का आईडी, क्लिपबोर्ड पर कॉपी करें.
ConsentDebugSettings.Builder().addTestDeviceHashedId()को कॉल करने के लिए, अपने कोड में बदलाव करें. साथ ही, अपने टेस्ट डिवाइस के आईडी की सूची पास करें.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 टूल की मदद से, अपने ऐप्लिकेशन के व्यवहार की जांच की जा सकती है. इसके लिए, DebugGeography का इस्तेमाल करके यह माना जाता है कि डिवाइस अलग-अलग इलाकों में है. जैसे, यूरोपियन इकनॉमिक एरिया (ईईए), यूनाइटेड किंगडम (यूके) और स्विट्ज़रलैंड. DebugGeography. ध्यान दें कि डीबग सेटिंग सिर्फ़ टेस्ट डिवाइसों पर काम करती हैं.
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 टूल की स्थिति रीसेट करना मददगार साबित हो सकता है. इससे, उपयोगकर्ता के पहले इंस्टॉल करने के अनुभव को सिम्युलेट किया जा सकता है.
इसके लिए, SDK टूल में reset() तरीका उपलब्ध है.
Java
consentInformation.reset();
Kotlin
consentInformation.reset()
GitHub पर मौजूद उदाहरण
इस पेज पर बताए गए UMP SDK टूल के इंटिग्रेशन का पूरा उदाहरण, UmpExample में देखें.