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