אני רוצה לנסות

בכפוף להסכמת משתמשים של Google באיחוד האירופי מדיניות, עליך להציג הודעות גילוי נאות מסוימות למשתמשים באזור הכלכלי האירופי (EEA) בנוסף עם בריטניה ולקבל את הסכמתם לשימוש בקובצי Cookie או באמצעים אחרים לאחסון מקומי, במקומות שבהם הדבר נדרש על פי חוק, וכן להשתמש במידע אישי (כגון מזהה פרסום) לצורך הצגת מודעות. המדיניות הזו משקפת את הדרישות שמפורטות ב-ePrivacy Directive (ההנחיה בנושא פרטיות ותקשורת אלקטרונית) של האיחוד האירופי General Data Protection Regulation (התקנות הכלליות להגנה על מידע, GDPR).

כדי לעזור לבעלי תוכן דיגיטלי למלא את החובות שלהם במסגרת המדיניות הזו, Google מציעה User Messaging Platform (UMP) SDK. UMP SDK עודכן כדי לתמוך בהתאם לתקנים העדכניים ביותר של IAB. כל ההגדרות האישיות האלה יכולות עכשיו מטופל AdMob בפרטיות העברת הודעות.

דרישות מוקדמות

איך יוצרים את סוג ההודעה

ליצור הודעות למשתמשים באמצעות אחד הסוגים הזמינים של הודעות למשתמשים בקטע פרטיות העברת הודעות AdMob חשבון. UMP SDK מנסה להציג הודעת המשתמש נוצרה מ- AdMob מזהה האפליקציה שמוגדרים בפרויקט. אם לא הוגדרה הודעה לאפליקציה, ה-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 (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() ב- ConsentForm המחלקה כדי לטעון טופס הסכמה. אם נדרש סטטוס הסכמה, ערכת ה-SDK טוענת טופס ומציגה אותו מיד שסופקו. Action<FormError> callback נקרא אחרי סגירה של הטופס. אם לא נדרשת הסכמה, Action<FormError> callback נקראת באופן מיידי.

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 עבור הטופס שלך.

בקשה להצגת מודעות

לפני ששולחים בקשה להצגת מודעות באפליקציה, צריך לבדוק אם קיבלת הסכמה מהמשתמש באמצעות CanRequestAds(). יש שתי פלטפורמות מקומות שצריך לבדוק במהלך קבלת ההסכמה:

  1. אחרי שהתקבלה הסכמה בסשן הנוכחי.
  2. מיד לאחר שהתקשרת אל 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. מטמיעים רכיב בממשק המשתמש, כמו לחצן בדף ההגדרות של האפליקציה, שיכול להפעיל טופס של אפשרויות פרטיות.
  2. אחרי LoadAndShowConsentFormIfRequired() שמסיימים, בודקים PrivacyOptionsRequirementStatus כדי לקבוע אם להציג רכיב ממשק המשתמש שיכול להציג את הטופס של אפשרויות הפרטיות.
  3. כשמשתמש יוצר אינטראקציה עם רכיב בממשק המשתמש שלך, מתבצעת קריאה ShowPrivacyOptionsForm() כדי להציג את הטופס כך שהמשתמש יוכל לעדכן את אפשרויות הפרטיות שלהם בכל שלב.

הדוגמה הבאה ממחישה איך להציג את טופס אפשרויות הפרטיות Button.

[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;
        }
    });
}

בדיקה

כדי לבדוק את השילוב באפליקציה במהלך הפיתוח, צריך לפעול לפי השלבים הבאים: כדי לרשום את מכשיר הבדיקה באופן פרוגרמטי. חשוב להסיר את שמגדיר את מזהי מכשירי הבדיקה האלה לפני השקת האפליקציה.

  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 מאפשר לבדוק את התנהגות האפליקציה כאילו המכשיר שנמצאים ב-EEA או בבריטניה דרך 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 כדי שיהיה אפשר לדמות את חוויית ההתקנה הראשונה של המשתמש. ה-SDK מספק את Reset() השיטה לעשות זאת.

ConsentInformation.Reset();

דוגמאות ב-GitHub