שנתחיל?

בהתאם למדיניות 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.
}

טעינה והצגה של טופס הסכמה במקרה הצורך

חשוב: ממשקי ה-API הבאים תואמים ל-UMP SDK בגרסה 2.1.0 ואילך.

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