शुरू करें

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

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

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

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

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

आप यहां अपना ऐप्लिकेशन आईडी देख सकते हैं: Ad Manager का यूज़र इंटरफ़ेस (यूआई). आईडी को अपने के लिए यहां दिए गए कोड स्निपेट का इस्तेमाल करें:

आपको हर ऐप्लिकेशन में, उपयोगकर्ता की सहमति से जुड़ी जानकारी अपडेट करने का अनुरोध करना चाहिए 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 (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.
}

अगर ज़रूरी हो, तो निजता से जुड़ा मैसेज फ़ॉर्म लोड करें और उसे प्रज़ेंट करें

सहमति की अप-टू-डेट स्थिति मिलने के बाद, 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.
    });
}

अगर आपको उपयोगकर्ता के चुनने या खारिज करने के बाद कोई कार्रवाई करने की ज़रूरत है फ़ॉर्म भरने के बाद, उस लॉजिक को Action<FormError> callback को भी डाउनलोड करें.

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

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

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

  1. देखें 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.
        if (_privacyButton != null)
        {
            _privacyButton.interactable =
                ConsentInformation.PrivacyOptionsRequirementStatus ==
                PrivacyOptionsRequirementStatus.Required;
        }
    });
}

विज्ञापन जोड़ने का अनुरोध करें

अपने ऐप्लिकेशन में विज्ञापनों का अनुरोध करने से पहले, देख लें कि आपको सहमति मिली है या नहीं का इस्तेमाल कर रहे हैं. दो सहमति लेते समय चेक करने के लिए स्थान:

  • मौजूदा सेशन में सहमति लेने के बाद.
  • आपके कॉल करने के तुरंत बाद Update(). ऐसा हो सकता है कि सहमति पिछले सेशन में ली गई हो. इंतज़ार के समय के तौर पर सबसे सही तरीका है, हमारा सुझाव है कि कॉलबैक पूरा होने का इंतज़ार न करें, ताकि आप ऐप्लिकेशन लॉन्च होने के बाद, विज्ञापनों को लोड करना तुरंत शुरू कर दें.

अगर सहमति इकट्ठा करने की प्रक्रिया के दौरान कोई गड़बड़ी होती है, तो आपको अब भी विज्ञापनों का अनुरोध करने की कोशिश नहीं की जाती. 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 टूल की मदद से, ऐप्लिकेशन के काम करने के तरीके को ऐसे टेस्ट किया जा सकता है जैसे कि डिवाइस ईईए या यूके में रहने वाले लोग हैं, जो the DebugGeography field on ConsentDebugSettingsका इस्तेमाल करते हैं. ध्यान दें कि डीबग सेटिंग सिर्फ़ टेस्ट डिवाइसों पर काम करती हैं.

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 पर उदाहरण