शुरू करना

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

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

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

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

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

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

  • सहमति लेना ज़रूरी है या नहीं. उदाहरण के लिए, पहली बार सहमति लेनी हो या सहमति देने से जुड़ा पिछला फ़ैसला खत्म हो गया हो.
  • निजता विकल्पों के एंट्री पॉइंट की ज़रूरत है या नहीं. निजता से जुड़े कुछ मैसेज के लिए, ऐप्लिकेशन को उपयोगकर्ताओं को यह अनुमति देनी होती है कि वे किसी भी समय निजता से जुड़े विकल्पों में बदलाव कर सकें.
void Start()
{
    // Create a ConsentRequestParameters object.
    ConsentRequestParameters request = new ConsentRequestParameters();

    // Check the current consent information status.
    ConsentInformation.Update(request, OnConsentInfoUpdated);
}

void OnConsentInfoUpdated(FormError consentError)
{
    // If the error is null, the consent information state was updated.
    if (consentError != null)
    {
        // Handle the error.
        UnityEngine.Debug.LogError(consentError);
        return;
    }
}

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

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

void Start()
{
    // Create a ConsentRequestParameters object.
    ConsentRequestParameters request = new ConsentRequestParameters();

    // Check the current consent information status.
    ConsentInformation.Update(request, OnConsentInfoUpdated);
}

void OnConsentInfoUpdated(FormError consentError)
{
    if (consentError != null)
    {
        // Handle the error.
        UnityEngine.Debug.LogError(consentError);
        return;
    }

    // If the error is null, the consent information state was updated.
    // You are now ready to check if a form is available.
    ConsentForm.LoadAndShowConsentFormIfRequired((FormError formError) =>
    {
        if (formError != null)
        {
            // Consent gathering failed.
            UnityEngine.Debug.LogError(consentError);
            return;
        }

        // Consent has been gathered.
    });
}

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

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

निजता के विकल्पों वाला एंट्री पॉइंट लागू करने के लिए, यह तरीका अपनाएं:

  1. Update() को कॉल करने के बाद, PrivacyOptionsRequirementStatus देखें और पता लगाएं कि निजता विकल्पों का एंट्री पॉइंट ज़रूरी है या नहीं.
  2. अगर ज़रूरी हो, तो अपने ऐप्लिकेशन में ऐसा यूज़र इंटरफ़ेस (यूआई) एलिमेंट जोड़ें जो साफ़ तौर पर दिखता हो और जिसके साथ इंटरैक्ट किया जा सकता हो. इससे, निजता के विकल्पों वाले एंट्री पॉइंट के तौर पर काम किया जा सकेगा. अगर निजता एंट्री पॉइंट की ज़रूरत नहीं है, तो अपने यूज़र इंटरफ़ेस (यूआई) एलिमेंट को इस तरह कॉन्फ़िगर करें कि वह दिखे नहीं और उसके साथ इंटरैक्ट न किया जा सके.
  3. ShowPrivacyOptionsForm() का इस्तेमाल करके, निजता के विकल्पों वाला फ़ॉर्म दिखाएं.

यहां दिए गए कोड के उदाहरण में, इन चरणों को दिखाया गया है:

[SerializeField, Tooltip("Button to show the privacy options form.")]
private Button _privacyButton;

private void Start()
{
  // Enable the privacy settings button.
  if (_privacyButton != null)
  {
      _privacyButton.onClick.AddListener(UpdatePrivacyButton);
      // Disable the privacy settings button by default.
      _privacyButton.interactable = false;
  }
}

/// <summary>
/// Shows the privacy options form to the user.
/// </summary>
public void ShowPrivacyOptionsForm()
{
    Debug.Log("Showing privacy options form.");

    ConsentForm.ShowPrivacyOptionsForm((FormError showError) =>
    {
        if (showError != null)
        {
            Debug.LogError("Error showing privacy options form with error: " + showError.Message);
        }
        // Enable the privacy settings button.
        UpdatePrivacyButton();
    });
}

/// <summary>
/// Updates the privacy buttons visual state based on the consent information.
/// </summary>
void UpdatePrivacyButton()
{
    if (_privacyButton != null)
    {
        _privacyButton.interactable =
            ConsentInformation.PrivacyOptionsRequirementStatus ==
                PrivacyOptionsRequirementStatus.Required;
    }
}

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

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

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

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

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

void Start()
{
    // Create a ConsentRequestParameters object.
    ConsentRequestParameters request = new ConsentRequestParameters();

    // Check the current consent information status.
    ConsentInformation.Update(request, OnConsentInfoUpdated);
}

void OnConsentInfoUpdated(FormError consentError)
{
    if (consentError != null)
    {
        // Handle the error.
        UnityEngine.Debug.LogError(consentError);
        return;
    }

    // If the error is null, the consent information state was updated.
    // You are now ready to check if a form is available.
    ConsentForm.LoadAndShowConsentFormIfRequired((FormError formError) =>
    {
        if (formError != null)
        {
            // Consent gathering failed.
            UnityEngine.Debug.LogError(consentError);
            return;
        }

        // Consent has been gathered.
        if (ConsentInformation.CanRequestAds())
        {
            MobileAds.Initialize((InitializationStatus initstatus) =>
            {
              // TODO: Request an ad.
            });
        }
    });
    
}

टेस्ट करना

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

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

    Android

    Use new ConsentDebugSettings.Builder().addTestDeviceHashedId("33BE2250B43518CCDA7DE426D04EE231")
    to set this as a debug device.
    

    iOS

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

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

    void Start()
    {
        var debugSettings = new ConsentDebugSettings
        {
            TestDeviceHashedIds =
            new List<string>
            {
                "TEST-DEVICE-HASHED-ID"
            }
        };
    
        // Create a ConsentRequestParameters object.
        ConsentRequestParameters request = new ConsentRequestParameters
        {
            ConsentDebugSettings = debugSettings,
        };
    
        // Check the current consent information status.
        ConsentInformation.Update(request, OnConsentInfoUpdated);
    }
    

किसी देश या इलाके को टारगेट करना

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

void Start()
{
    var debugSettings = new ConsentDebugSettings
    {
        // Geography appears as in EEA for debug devices.
        DebugGeography = DebugGeography.EEA,
        TestDeviceHashedIds = new List<string>
        {
            "TEST-DEVICE-HASHED-ID"
        }
    };

    // Create a ConsentRequestParameters object.
    ConsentRequestParameters request = new ConsentRequestParameters
    {
        ConsentDebugSettings = debugSettings,
    };

    // Check the current consent information status.
    ConsentInformation.Update(request, OnConsentInfoUpdated);
}

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

ConsentInformation.Reset();

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

इस पेज पर दिए गए UMP SDK टूल के इंटिग्रेशन का पूरा उदाहरण, HelloWorld में देखें.