שנתחיל?

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

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

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

יצירת סוג הודעה

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

פרטים נוספים זמינים במאמר מידע על הכלי 'פרטיות והודעות'

עליך לבקש עדכון של פרטי ההסכמה של המשתמש בכל השקה של האפליקציה, באמצעות requestConsentInfoUpdate(). ההגדרה הזו קובעת אם המשתמש צריך להביע הסכמה אם עדיין לא עשה זאת, או אם תוקף ההסכמה פג.

דוגמה לבדיקת הסטטוס של הפעלת אפליקציה:

@override
void initState() {
  super.initState();

  // Create a ConsentRequestParameters object.
  final params = ConsentRequestParameters();

  // Request an update for the consent information.
  ConsentInformation.instance.requestConsentInfoUpdate(
    params,
    () async {
      // TODO: Load and present the consent form.
    },
    (FormError error) {
      // Handle the error.
    },
  );
}

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

אחרי שמקבלים את סטטוס ההסכמה העדכני ביותר, צריך להתקשר לכיתהloadAndShowConsentFormIfRequired() ConsentForm בכיתה כדי לטעון טופס הסכמה. אם נדרש סטטוס הסכמה, ה-SDK יטען טופס ויוצג מיד מהטופס . callback נקרא אחרי סגירת הטופס. אם לא נדרשת הסכמה, callback נקרא באופן מיידי.

@override
void initState() {
  super.initState();

  // Create a ConsentRequestParameters object.
  final params = ConsentRequestParameters();

  // Request an update for the consent information.
  ConsentInformation.instance.requestConsentInfoUpdate(
    params,
    () async {
      ConsentForm.loadAndShowConsentFormIfRequired((loadAndShowError) {
        if (loadAndShowError != null) {
          // Consent gathering failed.
        }

        // Consent has been gathered.
      });
    },
    (FormError error) {
      // Handle the error.
    },
  );
}

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

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

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

  1. אחרי שהמערכת תאסוף את ההסכמה בסשן הנוכחי.
  2. מיד לאחר שתתקשר אל requestConsentInfoUpdate(). יכול להיות שקיבלנו הסכמה בסשן הקודם. כשיטה מומלצת לזמן אחזור, מומלץ לא להמתין עד שהקריאה החוזרת תסתיים, כדי שתוכלו להתחיל לטעון את המודעות בהקדם האפשרי אחרי הפעלת האפליקציה.

גם אם מתרחשת שגיאה בתהליך איסוף ההסכמה, עדיין מומלץ לנסות לבקש מודעות. ה-UMP SDK משתמש בסטטוס ההסכמה מהסשן הקודם.

class AppExampleState extends State<AppExample> {

  // Use a bool to initialize the Mobile Ads SDK and load ads once.
  var _isMobileAdsInitializeCalled = false;

  @override
  void initState() {
    super.initState();

    // Create a ConsentRequestParameters object.
    final params = ConsentRequestParameters();

    // Request an update for the consent information.
    ConsentInformation.instance.requestConsentInfoUpdate(
      params,
      () async {
        ConsentForm.loadAndShowConsentFormIfRequired((loadAndShowError) {
          if (loadAndShowError != null) {
            // Consent gathering failed.
          }

          // Consent has been gathered.
          _initializeMobileAdsSDK();
        });
      },
      (FormError error) {
        // Handle the error.
      },
    );

    // Check if you can initialize the Mobile Ads SDK in parallel while
    // checking for new consent information. Consent obtained in the
    // previous session can be used to request ads.
    _initializeMobileAdsSDK();
  }

  void _initializeMobileAdsSDK() async {
    if (_isMobileAdsInitializeCalled) {
      return;
    }

    // Initialize the Mobile Ads SDK if the SDK has gathered consent aligned with
    // the app's configured messages.
    var canRequestAds = await ConsentInformation.instance.canRequestAds();
    if (canRequestAds) {
      setState(() {
        _isMobileAdsInitializeCalled = true;
      });

      // Initialize the Mobile Ads SDK.
      MobileAds.instance.initialize();

      // TODO: Request an ad.
    }
  }
}

אפשרויות פרטיות

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

לשם כך:

  1. מטמיעים רכיב בממשק המשתמש, כמו לחצן בדף ההגדרות של האפליקציה, שיכול להפעיל טופס של אפשרויות פרטיות.
  2. בסיום loadAndShowConsentFormIfRequired() מסמנים את התיבהgetPrivacyOptionsRequirementStatus() כדי לקבוע אם להציג את הרכיב בממשק המשתמש שיכול להציג את טופס אפשרויות הפרטיות.
  3. כשמשתמש יוצר אינטראקציה עם הרכיב בממשק המשתמש, צריך לבצע קריאה אל showPrivacyOptionsForm() כדי להציג את הטופס כדי שהמשתמש יוכל לעדכן את אפשרויות הפרטיות שלו בכל שלב.
class AppExampleState extends State<AppExample> {
  static const _privacySettingsText = 'Privacy Settings';

  // Use a bool to initialize the Mobile Ads SDK and load ads once.
  var _isMobileAdsInitializeCalled = false;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'App Example',
      home: Scaffold(
          appBar: AppBar(
            title: const Text('App Example'),
            actions: _isMobileAdsSDKInitialized
                // Regenerate the options menu to include a privacy setting.
                ? _privacySettingsAppBarAction()
                : null
          ),
          body: // ...
      ),
    );
  }

  List<Widget> _privacySettingsAppBarAction() {
    return <Widget>[
      FutureBuilder(
          future: ConsentInformation.instance.isPrivacyOptionsRequired(),
          builder: (context, snapshot) {
            final bool visibility = snapshot.data ?? false;
            return Visibility(
                visible: visibility,
                child: PopupMenuButton<String>(
                  onSelected: (String result) {
                    if (result == _privacySettingsText) {
                      ConsentForm.showPrivacyOptionsForm((formError) {
                        if (formError != null) {
                          debugPrint(
                              "${formError.errorCode}: ${formError.message}");
                        }
                      });
                    }
                  },
                  itemBuilder: (BuildContext context) =>
                      <PopupMenuEntry<String>>[
                    const PopupMenuItem<String>(
                        value: _privacySettingsText,
                        child: Text(_privacySettingsText))
                  ],
                ));
          })
    ];
  }
}

בדיקה

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

  1. התקשרות אל requestConsentInfoUpdate().
  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. משנים את הקוד כדי להתקשר ConsentDebugSettings.testIdentifiers ולעבור ברשימה של מזהי מכשירי הבדיקה.

    ConsentDebugSettings debugSettings = ConsentDebugSettings(
      testIdentifiers: ["TEST-DEVICE-HASHED-ID"],
    );
    
    ConsentRequestParameters params =
        ConsentRequestParameters(consentDebugSettings: debugSettings);
    
    ConsentInformation.instance.requestConsentInfoUpdate(params, () async {
      // ...
    };
    

אילוץ מיקום גיאוגרפי

באמצעות UMP SDK אפשר לבדוק את התנהגות האפליקציה כאילו המכשיר נמצא ב-EEA או בבריטניה באמצעות the DebugGeography field on ConsentDebugSettings. שימו לב שהגדרות ניפוי הבאגים פועלות רק במכשירי בדיקה.

ConsentDebugSettings debugSettings = ConsentDebugSettings(
  debugGeography: DebugGeography.debugGeographyEea,
  testIdentifiers: ["TEST-DEVICE-HASHED-ID"],
);

ConsentRequestParameters params =
    ConsentRequestParameters(consentDebugSettings: debugSettings);

ConsentInformation.instance.requestConsentInfoUpdate(params, () async {
  // ...
};

בבדיקת האפליקציה באמצעות UMP SDK, כדאי לאפס את המצב של ה-SDK כדי שתוכלו לדמות את חוויית ההתקנה הראשונה של המשתמש. ה-SDK מספק את השיטה reset() לעשות זאת.

ConsentInformation.instance.reset();