ภายใต้นโยบายความยินยอมของผู้ใช้ EU ของ Google คุณต้องเปิดเผยข้อมูลบางอย่างต่อผู้ใช้ในเขตเศรษฐกิจยุโรป (EEA) รวมถึงสหราชอาณาจักร และขอความยินยอมในการใช้คุกกี้หรือพื้นที่เก็บข้อมูลอื่นในเครื่องในกรณีที่กฎหมายกำหนด และใช้ข้อมูลส่วนตัว (เช่น AdID) เพื่อแสดงโฆษณา นโยบายนี้เป็นผลมาจากข้อกำหนดด้าน ePrivacy และกฎระเบียบให้ความคุ้มครองข้อมูลส่วนบุคคลของผู้บริโภค (GDPR) ของสหภาพยุโรป
Google มี SDK สำหรับ User Messaging Platform (UMP) เพื่อสนับสนุนให้ผู้เผยแพร่โฆษณาปฏิบัติตามหน้าที่ของตนภายใต้นโยบายนี้ UMP SDK ได้รับการอัปเดตให้รองรับ มาตรฐาน IAB ล่าสุด ตอนนี้การกำหนดค่าทั้งหมดนี้จัดการได้ง่ายๆ ใน Ad Manager ความเป็นส่วนตัวและการแสดงข้อความแจ้งผู้ใช้
สิ่งที่ต้องดำเนินการก่อน
- ทำตามคู่มือเริ่มต้นใช้งาน
- หากคุณกําลังดําเนินการตามข้อกำหนดที่เกี่ยวข้องกับ GDPR โปรดอ่าน ข้อกําหนดของ IAB ส่งผลต่อข้อความขอความยินยอมในสหภาพยุโรปอย่างไร
สร้างประเภทข้อความ
สร้างข้อความสำหรับผู้ใช้โดยใช้ ประเภทข้อความสำหรับผู้ใช้ที่มีให้บริการ ในแท็บความเป็นส่วนตัวและการรับส่งข้อความของบัญชี 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()
หรือไม่ ขณะที่รวบรวมความยินยอม
คุณจะมี 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.
}
}
}
ตัวเลือกความเป็นส่วนตัว
แบบฟอร์มความยินยอมบางแบบฟอร์มกำหนดให้ผู้ใช้แก้ไขความยินยอมได้ทุกเมื่อ ทำตามขั้นตอนต่อไปนี้เพื่อใช้ปุ่มตัวเลือกความเป็นส่วนตัว หากจำเป็น
ทั้งสองสามารถทำได้โดยดำเนินการดังนี้
- ใช้องค์ประกอบ UI เช่น ปุ่มในหน้าการตั้งค่าของแอปที่สามารถทริกเกอร์แบบฟอร์มตัวเลือกความเป็นส่วนตัว
- เมื่อ
loadAndShowConsentFormIfRequired()
เสร็จสิ้นแล้ว ให้เลือกgetPrivacyOptionsRequirementStatus()
เพื่อระบุว่าจะแสดงองค์ประกอบ UI ที่แสดงแบบฟอร์มตัวเลือกความเป็นส่วนตัวได้หรือไม่ - เมื่อผู้ใช้โต้ตอบกับองค์ประกอบ UI ให้เรียกใช้
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))
],
));
})
];
}
}
การทดสอบ
หากต้องการทดสอบการผสานรวมในแอประหว่างการพัฒนา โปรดทำตามขั้นตอนเหล่านี้เพื่อลงทะเบียนอุปกรณ์ทดสอบแบบเป็นโปรแกรม อย่าลืมนำโค้ดที่กำหนดรหัสอุปกรณ์ทดสอบเหล่านี้ออกก่อนที่จะเผยแพร่แอป
- โทร
requestConsentInfoUpdate()
ตรวจสอบเอาต์พุตบันทึกเพื่อหาข้อความที่คล้ายกับตัวอย่างต่อไปนี้ ซึ่งจะแสดงรหัสอุปกรณ์และวิธีเพิ่มเป็นอุปกรณ์ทดสอบ
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]
คัดลอกรหัสอุปกรณ์ทดสอบไปยังคลิปบอร์ด
แก้ไขโค้ดเพื่อ เรียกใช้
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();