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

בהתאם למדיניות 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 יחזיר שגיאה.

לפרטים נוספים, ראו מידע על פרטיות והודעות.

צריך לבקש עדכון של פרטי ההסכמה של המשתמש בכל השקת אפליקציה, באמצעות 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();