แชร์ความคิดเห็นและช่วยปรับปรุงแผนกลยุทธ์ SDK โฆษณาในอุปกรณ์เคลื่อนที่ของ Google โปรดทําแบบสํารวจประจําปีเกี่ยวกับ SDK โฆษณาในอุปกรณ์เคลื่อนที่ของ Google ปี 2023 ก่อนวันที่ 5 พฤษภาคม 2023

เริ่มต้น

จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ

ภายใต้นโยบายการยินยอมของผู้ใช้ EU ของ Google คุณต้องเปิดเผยข้อมูลบางอย่างต่อผู้ใช้ในเขตเศรษฐกิจยุโรป (EEA) และสหราชอาณาจักร รวมถึงขอความยินยอมจากผู้ใช้ให้ใช้คุกกี้หรือพื้นที่เก็บข้อมูลอื่นในเครื่องในกรณีที่กฎหมายกําหนด รวมถึงเพื่อใช้ข้อมูลส่วนตัว (เช่น AdID) ในการแสดงโฆษณา นโยบายนี้เป็นผลมาจากข้อกําหนดด้าน ePrivacy และกฎระเบียบให้ความคุ้มครองข้อมูลส่วนบุคคลของผู้บริโภค (GDPR) ของสหภาพยุโรป

เพื่อสนับสนุนผู้เผยแพร่โฆษณาในการปฏิบัติตามหน้าที่ของตนภายใต้นโยบายนี้ Google จึงเสนอ SDK สําหรับ User Messaging Platform (UMP) UMP SDK ได้รับการอัปเดตให้รองรับมาตรฐาน IAB ล่าสุดแล้ว และตอนนี้คุณยังกําหนดค่าต่างๆ ใน AdMob ความเป็นส่วนตัวและการแสดงข้อความแจ้งผู้ใช้ได้อย่างสะดวก

สิ่งที่ต้องดำเนินการก่อน

ประเภทข้อความสําหรับผู้ใช้

ดู ประเภทข้อความสําหรับผู้ใช้ เพื่อดูรายการข้อความที่รองรับทั้งหมด ดูคําแนะนําเฉพาะเกี่ยวกับการใช้งานข้อความแต่ละประเภทได้ที่แถบนําทางด้านซ้าย

ติดตั้งด้วย Gradle

หากคุณใช้ SDK โฆษณาในอุปกรณ์เคลื่อนที่ของ Google เวอร์ชัน 19.8.0 ขึ้นไป SDK ของ UMP จะรวมอยู่ในแพ็กเกจ หากคุณใช้ SDK โฆษณาในอุปกรณ์เคลื่อนที่เวอร์ชันก่อนหน้า ให้รวม SDK สําหรับ UMP ไว้ใน build.gradle ของแอป ดังนี้

dependencies {
    // This dependency is automatically included by Google Mobile Ads SDK 19.8.0
    // or higher.
    implementation 'com.google.android.ump:user-messaging-platform:2.0.0'
}

หลังจากแก้ไข build.gradle ของแอปแล้ว อย่าลืมซิงค์โปรเจ็กต์กับไฟล์ Gradle

ถัดไป ค้นหารหัสแอปของคุณ และเพิ่มลงใน AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.rewardedinterstitialexample">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <!-- Sample app ID: ca-app-pub-3940256099942544~3347511713 -->
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

พิจารณาว่าจําเป็นต้องแสดงข้อความหรือไม่

คุณควรขออัปเดตข้อมูลความยินยอมของผู้ใช้ในทุกการเปิดตัวแอป โดยใช้ requestConsentInfoUpdate() ก่อนโหลดแบบฟอร์ม กรณีนี้จะกําหนดว่าผู้ใช้ต้องให้ความยินยอมหรือไม่ หากยังไม่ได้ดําเนินการ ความยินยอมของผู้ใช้หมดอายุหรือไม่

ใช้ข้อมูลที่เก็บไว้ในออบเจ็กต์ consentInformationเมื่อคุณนําเสนอแบบฟอร์มเมื่อจําเป็น

ตัวอย่างวิธีตรวจสอบสถานะการเริ่มต้นใช้งานแอปมีดังนี้

Java

package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.google.android.ump.ConsentForm;
import com.google.android.ump.ConsentInformation;
import com.google.android.ump.ConsentRequestParameters;
import com.google.android.ump.FormError;
import com.google.android.ump.UserMessagingPlatform;

public class MainActivity extends AppCompatActivity {
    private ConsentInformation consentInformation;
    private ConsentForm consentForm;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Set tag for under age of consent. false means users are not under
        // age.
        ConsentRequestParameters params = new ConsentRequestParameters
            .Builder()
            .setTagForUnderAgeOfConsent(false)
            .build();

        consentInformation = UserMessagingPlatform.getConsentInformation(this);
        consentInformation.requestConsentInfoUpdate(
            this,
            params,
            new ConsentInformation.OnConsentInfoUpdateSuccessListener() {
                @Override
                public void onConsentInfoUpdateSuccess() {
                    // The consent information state was updated.
                    // You are now ready to check if a form is available.
                }
            },
            new ConsentInformation.OnConsentInfoUpdateFailureListener() {
                @Override
                public void onConsentInfoUpdateFailure(FormError formError) {
                    // Handle the error.
                }
            });
    }
}

Kotlin

Coming soon.

โหลดแบบฟอร์ม (หากมี)

ก่อนแสดงแบบฟอร์ม คุณต้องพิจารณาว่ามีแบบฟอร์มที่ใช้ได้หรือไม่ แบบฟอร์มที่ไม่พร้อมใช้งานอาจเป็นเพราะผู้ใช้เปิดใช้การติดตามโฆษณาแบบจํากัด หรือคุณได้ติดแท็กแบบฟอร์มว่ามีอายุต่ํากว่าอายุที่ให้ความยินยอมได้

หากต้องการตรวจสอบความพร้อมใช้งานของแบบฟอร์ม ให้ใช้the isConsentFormAvailable() method on the ConsentInformation instance ที่คุณสร้างไว้ก่อนหน้านี้

จากนั้นเพิ่มเมธอด Wrapper เพื่อโหลดแบบฟอร์ม ดังนี้

Java

...
       consentInformation.requestConsentInfoUpdate(
           this,
           params,
           new ConsentInformation.OnConsentInfoUpdateSuccessListener() {
               @Override
               public void onConsentInfoUpdateSuccess() {
                   // The consent information state was updated.
                   // You are now ready to check if a form is available.
                   if (consentInformation.isConsentFormAvailable()) {
                       loadForm();
                   }
               }
           },
           new ConsentInformation.OnConsentInfoUpdateFailureListener() {
               @Override
               public void onConsentInfoUpdateFailure(FormError formError) {
                   // Handle the error.

               }
            });
    }

    public void loadForm() {

    }
}

Kotlin

Coming soon.

หากต้องการโหลดแบบฟอร์ม ให้ใช้ the static loadConsentForm() method on the UserMessagingPlatform class

Java

public void loadForm() {
    // Loads a consent form. Must be called on the main thread.
    UserMessagingPlatform.loadConsentForm(
        this,
        new UserMessagingPlatform.OnConsentFormLoadSuccessListener() {
            @Override
            public void onConsentFormLoadSuccess(ConsentForm consentForm) {
                MainActivity.this.consentForm = consentForm;
            }
        },
        new UserMessagingPlatform.OnConsentFormLoadFailureListener() {
            @Override
            public void onConsentFormLoadFailure(FormError formError) {
                // Handle the error
            }
        }
    );
}

Kotlin

Coming soon.

นําเสนอแบบฟอร์มหากจําเป็น

หลังจากที่กําหนดความพร้อมใช้งานของแบบฟอร์มและโหลดแล้ว ให้ใช้เมธอดshow() บนอินสแตนซ์ConsentForm เพื่อนําเสนอแบบฟอร์ม

ใช้ออบเจ็กต์consentInformation จากค่าเริ่มต้นเพื่อตรวจสอบเมธอดconsent status และอัปเดตเมธอดloadForm() ดังนี้

Java

public void loadForm() {
    UserMessagingPlatform.loadConsentForm(
        this,
        new UserMessagingPlatform.OnConsentFormLoadSuccessListener() {
            @Override
            public void onConsentFormLoadSuccess(ConsentForm consentForm) {
                MainActivity.this.consentForm = consentForm;
                if(consentInformation.getConsentStatus() == ConsentInformation.ConsentStatus.REQUIRED) {
                    consentForm.show(
                        MainActivity.this,
                            new ConsentForm.OnConsentFormDismissedListener() {
                                @Override
                                public void onConsentFormDismissed(@Nullable FormError formError) {
                                    // Handle dismissal by reloading form.
                                    loadForm();
                                }
                            });

                }

            }
        },
        new UserMessagingPlatform.OnConsentFormLoadFailureListener() {
            @Override
            public void onConsentFormLoadFailure(FormError formError) {
                /// Handle Error.
            }
        }
   );
}

Kotlin

Coming soon.

หากคุณจําเป็นต้องดําเนินการใดๆ หลังจากผู้ใช้เลือกตัวเลือกหรือปิดแบบฟอร์มแล้ว ให้วางตรรกะนั้นในเครื่องจัดการหรือเรียกกลับสําหรับแบบฟอร์ม

การทดสอบ

บังคับภูมิศาสตร์

UMP SDK เป็นวิธีทดสอบพฤติกรรมของแอปเสมือนว่าอุปกรณ์อยู่ใน EEA หรือสหราชอาณาจักรโดยใช้ the setDebugGeography method on ConsentDebugSettings.Builder

คุณต้องระบุรหัสที่แฮชของอุปกรณ์ทดสอบในการตั้งค่าการแก้ไขข้อบกพร่องของแอปเพื่อให้ใช้ฟังก์ชันแก้ไขข้อบกพร่องได้ หากคุณเรียกใช้ requestConsentInfoUpdate() โดยไม่ตั้งค่านี้ แอปจะบันทึกแฮชรหัสที่จําเป็นเมื่อเรียกใช้

Java

ConsentDebugSettings debugSettings = new ConsentDebugSettings.Builder(this)
    .setDebugGeography(ConsentDebugSettings
    .DebugGeography
    .DEBUG_GEOGRAPHY_EEA)
    .addTestDeviceHashedId("TEST-DEVICE-HASHED-ID")
    .build();

ConsentRequestParameters params = new ConsentRequestParameters
    .Builder()
    .setConsentDebugSettings(debugSettings)
    .build();

consentInformation = UserMessagingPlatform.getConsentInformation(this);
consentInformation.requestConsentInfoUpdate(this, params,
    new ConsentInformation.OnConsentInfoUpdateSuccessListener() {
        @Override
        public void onConsentInfoUpdateSuccess() {
            // The consent information state was updated.
            // You are now ready to check if a form is available.
        }
    },
    new ConsentInformation.OnConsentInfoUpdateFailureListener() {
        @Override
        public void onConsentInfoUpdateFailure(FormError formError) {
            // Handle the error.
        }
    });

Kotlin

Coming soon.

DebugGeographyช่วยให้คุณมีตัวเลือกในการ ขยายภูมิศาสตร์เป็นอย่างใดอย่างหนึ่งต่อไปนี้

การแก้ไขข้อบกพร่องด้านภูมิศาสตร์ คำอธิบาย
DEBUG_GEOGRAPHY_DISABLED ปิดใช้งานการแก้ไขข้อบกพร่องทางภูมิศาสตร์แล้ว
DEBUG_GEOGRAPHY_EEA ภูมิศาสตร์จะปรากฏใน EEA สําหรับอุปกรณ์แก้ไขข้อบกพร่อง
DEBUG_GEOGRAPHY_NOT_EEA ภูมิศาสตร์ไม่แสดงใน EEA สําหรับอุปกรณ์แก้ไขข้อบกพร่อง

โปรดทราบว่าการตั้งค่าแก้ไขข้อบกพร่องใช้ได้เฉพาะในอุปกรณ์ทดสอบเท่านั้น ไม่จําเป็นต้องเพิ่มโปรแกรมจําลองลงในรายการรหัสอุปกรณ์เนื่องจากเปิดใช้การทดสอบโดยค่าเริ่มต้นอยู่แล้ว

ในการทดสอบแอปด้วย UMP SDK การรีเซ็ตสถานะ SDK อาจเป็นประโยชน์สําหรับคุณในการจําลองประสบการณ์การติดตั้งครั้งแรกของผู้ใช้ โดย SDK นี้มี reset() วิธีการให้ทําเช่นนี้

Java

consentInformation.reset();

Kotlin

consentInformation.reset()

คุณควรเรียก reset() ด้วยหากคุณตัดสินใจนํา UMP SDK ออกจากโปรเจ็กต์โดยสมบูรณ์