Google AB Kullanıcı Rızası Politikası uyarınca, Birleşik Krallık ile birlikte Avrupa Ekonomik Alanı'ndaki (AEA) kullanıcılarınıza belirli açıklamalar yapmanız ve yasal olarak gerekli olduğu durumlarda çerez veya başka yerel depolama bilgilerinin kullanımının yanı sıra reklam yayınlamak amacıyla kişisel verileri (AdID gibi) kullanmak için kullanıcıların iznini almanız gerekir. Bu politika AB eGizlilik Yönergesi ve Genel Veri Koruma Yönetmeliği (GDPR) gereksinimlerini yansıtmaktadır.
Google, yayıncıları bu politika kapsamındaki gereksinimleri yerine getirmeleri konusunda desteklemek için Kullanıcı Mesajlaşma Platformu (UMP) SDK'sını sunmaktadır. UMP SDK'sı, en son IAB standartlarını destekleyecek şekilde güncellenmiştir. Artık tüm bu yapılandırmalar AdMob gizlilik ve mesajlaşma bölümünden kolayca yönetilebilir.
Ön koşullar
- Başlangıç kılavuzunu tamamlayın
- Android API level 21 veya üstü
- GDPR ile ilgili şartlar üzerinde çalışıyorsanızIAB şartları AB kullanıcı rızası alma mesajlarını nasıl etkiler?
Mesaj türü oluşturma
Kullanıcı mesajlarını, AdMob hesabınızın Gizlilik ve mesajlaşma sekmesindeki kullanılabilir kullanıcı mesajı türlerinden birini kullanarak oluşturun. UMP SDK'sı, projenizde ayarlanan uygulama kimliğinden oluşturulan AdMob kullanıcı mesajı göstermeye çalışır. Uygulamanız için herhangi bir mesaj yapılandırılmazsa SDK bir hata döndürür.
Daha fazla bilgi için Gizlilik ve mesajlaşma hakkında bölümüne göz atın.
Gradle ile yükleyin
Google Kullanıcı Mesajlaşma Platformu SDK'sının bağımlılığını, modülünüzün uygulama düzeyindeki Gradle dosyasına (normalde app/build.gradle
) ekleyin:
dependencies {
implementation("com.google.android.ump:user-messaging-platform:2.2.0")
}
Uygulamanızın build.gradle
öğesinde değişiklikleri yaptıktan sonra, projenizi Gradle dosyalarıyla senkronize ettiğinizden emin olun.
Rıza bilgileri isteği
Her uygulama lansmanında requestConsentInfoUpdate()
kullanarak kullanıcının izin bilgilerinin güncellenmesini istemeniz gerekir. Bu durum, kullanıcınızın henüz yapmadıysa izin vermesi gerekip gerekmediğini veya izin süresinin dolup dolmadığını belirler.
Aşağıda, onCreate()
yönteminde durumu MainActivity
üzerinden nasıl kontrol edeceğinize dair bir örnek verilmiştir.
Java
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
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;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Create a ConsentRequestParameters object.
ConsentRequestParameters params = new ConsentRequestParameters
.Builder()
.build();
consentInformation = UserMessagingPlatform.getConsentInformation(this);
consentInformation.requestConsentInfoUpdate(
this,
params,
(OnConsentInfoUpdateSuccessListener) () -> {
// TODO: Load and show the consent form.
},
(OnConsentInfoUpdateFailureListener) requestConsentError -> {
// Consent gathering failed.
Log.w(TAG, String.format("%s: %s",
requestConsentError.getErrorCode(),
requestConsentError.getMessage()));
});
}
}
Kotlin
package com.example.myapplication
import com.google.android.ump.ConsentInformation
import com.google.android.ump.ConsentInformation.OnConsentInfoUpdateFailureListener
import com.google.android.ump.ConsentInformation.OnConsentInfoUpdateSuccessListener
import com.google.android.ump.ConsentRequestParameters
import com.google.android.ump.UserMessagingPlatform
class MainActivity : AppCompatActivity() {
private lateinit var consentInformation: ConsentInformation
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Create a ConsentRequestParameters object.
val params = ConsentRequestParameters
.Builder()
.build()
consentInformation = UserMessagingPlatform.getConsentInformation(this)
consentInformation.requestConsentInfoUpdate(
this,
params,
ConsentInformation.OnConsentInfoUpdateSuccessListener {
// TODO: Load and show the consent form.
},
ConsentInformation.OnConsentInfoUpdateFailureListener {
requestConsentError ->
// Consent gathering failed.
Log.w(TAG, "${requestConsentError.errorCode}: ${requestConsentError.message}")
})
}
}
İzin formunu yükleme ve gerekirse gösterme
Önemli: Aşağıdaki API'ler, UMP SDK'sının 2.1.0 veya sonraki sürümleriyle uyumludur.En güncel izin durumunu aldıktan sonra izin formu yüklemek içinConsentForm
sınıftanloadAndShowConsentFormIfRequired()
numaralı telefonu arayın. İzin durumu gerekiyorsa SDK bir form yükler ve sağlanan activityaracından hemen sunar. Form kapatıldıktan sonra callback
çağrı yapılır. İzin gerekli değilse callback
çağrılır.
Java
public class MainActivity extends AppCompatActivity {
private ConsentInformation consentInformation;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Create a ConsentRequestParameters object.
ConsentRequestParameters params = new ConsentRequestParameters
.Builder()
.build();
consentInformation = UserMessagingPlatform.getConsentInformation(this);
consentInformation.requestConsentInfoUpdate(
this,
params,
(OnConsentInfoUpdateSuccessListener) () -> {
UserMessagingPlatform.loadAndShowConsentFormIfRequired(
this,
(OnConsentFormDismissedListener) loadAndShowError -> {
if (loadAndShowError != null) {
// Consent gathering failed.
Log.w(TAG, String.format("%s: %s",
loadAndShowError.getErrorCode(),
loadAndShowError.getMessage()));
}
// Consent has been gathered.
}
);
},
(OnConsentInfoUpdateFailureListener) requestConsentError -> {
// Consent gathering failed.
Log.w(TAG, String.format("%s: %s",
requestConsentError.getErrorCode(),
requestConsentError.getMessage()));
});
}
}
Kotlin
class MainActivity : AppCompatActivity() {
private lateinit var consentInformation: ConsentInformation
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Create a ConsentRequestParameters object.
val params = ConsentRequestParameters
.Builder()
.build()
consentInformation = UserMessagingPlatform.getConsentInformation(this)
consentInformation.requestConsentInfoUpdate(
this,
params,
ConsentInformation.OnConsentInfoUpdateSuccessListener {
UserMessagingPlatform.loadAndShowConsentFormIfRequired(
this@MainActivity,
ConsentForm.OnConsentFormDismissedListener {
loadAndShowError ->
if (loadAndShowError != null) {
// Consent gathering failed.
Log.w(TAG, "${loadAndShowError.errorCode}: ${loadAndShowError.message}")
}
// Consent has been gathered.
}
)
},
ConsentInformation.OnConsentInfoUpdateFailureListener {
requestConsentError ->
// Consent gathering failed.
Log.w(TAG, "${requestConsentError.errorCode}: ${requestConsentError.message}")
})
}
}
Kullanıcı bir seçim yaptıktan veya formu kapattıktan sonra herhangi bir işlem gerçekleştirmeniz gerekirse bu mantığı formunuzun callbackiçine yerleştirin.
Reklam isteğinde bulun
Uygulamanızda reklam isteğinde bulunmadan önce, canRequestAds()
özelliğini kullanarak kullanıcıdan izin alıp almadığınızı kontrol edin. İzin alırken kontrol edilecek
iki yer vardır:
- Geçerli oturumda izin alındıktan sonra.
-
requestConsentInfoUpdate()
numaralı telefonu aradıktan hemen sonra. Önceki oturumda izin alınmış olabilir. Gecikmeye yönelik en iyi uygulama olarak, geri çağırmanın tamamlanmasını beklememenizi öneririz. Böylece uygulamanız kullanıma sunulduktan sonra mümkün olan en kısa sürede reklam yüklemeye başlayabilirsiniz.
İzin toplama sürecinde bir hata oluşursa yine de reklam istemeyi denemeniz gerekir. UMP SDK'sı, önceki oturumdaki izin durumunu kullanır.
Java
public class MainActivity extends AppCompatActivity {
private ConsentInformation consentInformation;
// Use an atomic boolean to initialize the Google Mobile Ads SDK and load ads once.
private final AtomicBoolean isMobileAdsInitializeCalled = new AtomicBoolean(false);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Create a ConsentRequestParameters object.
ConsentRequestParameters params = new ConsentRequestParameters
.Builder()
.build();
consentInformation = UserMessagingPlatform.getConsentInformation(this);
consentInformation.requestConsentInfoUpdate(
this,
params,
(OnConsentInfoUpdateSuccessListener) () -> {
UserMessagingPlatform.loadAndShowConsentFormIfRequired(
this,
(OnConsentFormDismissedListener) loadAndShowError -> {
if (loadAndShowError != null) {
// Consent gathering failed.
Log.w(TAG, String.format("%s: %s",
loadAndShowError.getErrorCode(),
loadAndShowError.getMessage()));
}
// Consent has been gathered.
if (consentInformation.canRequestAds()) {
initializeMobileAdsSdk();
}
}
);
},
(OnConsentInfoUpdateFailureListener) requestConsentError -> {
// Consent gathering failed.
Log.w(TAG, String.format("%s: %s",
requestConsentError.getErrorCode(),
requestConsentError.getMessage()));
});
// Check if you can initialize the Google Mobile Ads SDK in parallel
// while checking for new consent information. Consent obtained in
// the previous session can be used to request ads.
if (consentInformation.canRequestAds()) {
initializeMobileAdsSdk();
}
}
private void initializeMobileAdsSdk() {
if (isMobileAdsInitializeCalled.getAndSet(true)) {
return;
}
// Initialize the Google Mobile Ads SDK.
MobileAds.initialize(this);
// TODO: Request an ad.
// InterstitialAd.load(...);
}
}
Kotlin
class MainActivity : AppCompatActivity() {
private lateinit var consentInformation: ConsentInformation
// Use an atomic boolean to initialize the Google Mobile Ads SDK and load ads once.
private var isMobileAdsInitializeCalled = AtomicBoolean(false)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Create a ConsentRequestParameters object.
val params = ConsentRequestParameters
.Builder()
.build()
consentInformation = UserMessagingPlatform.getConsentInformation(this)
consentInformation.requestConsentInfoUpdate(
this,
params,
ConsentInformation.OnConsentInfoUpdateSuccessListener {
UserMessagingPlatform.loadAndShowConsentFormIfRequired(
this@MainActivity,
ConsentForm.OnConsentFormDismissedListener {
loadAndShowError ->
if (loadAndShowError != null) {
// Consent gathering failed.
Log.w(TAG, "${loadAndShowError.errorCode}: ${loadAndShowError.message}")
}
// Consent has been gathered.
if (consentInformation.canRequestAds()) {
initializeMobileAdsSdk()
}
}
)
},
ConsentInformation.OnConsentInfoUpdateFailureListener {
requestConsentError ->
// Consent gathering failed.
Log.w(TAG, "${requestConsentError.errorCode}: ${requestConsentError.message}")
})
// Check if you can initialize the Google Mobile Ads SDK in parallel
// while checking for new consent information. Consent obtained in
// the previous session can be used to request ads.
if (consentInformation.canRequestAds()) {
initializeMobileAdsSdk()
}
}
private fun initializeMobileAdsSdk() {
if (isMobileAdsInitializeCalled.getAndSet(true)) {
return
}
// Initialize the Google Mobile Ads SDK.
MobileAds.initialize(this)
// TODO: Request an ad.
// InterstitialAd.load(...)
}
}
Gizlilik seçenekleri
Bazı izin formları, kullanıcının dilediği zaman iznini değiştirmesini gerektirir. Gerekirse gizlilik seçenekleri düğmesi uygulamak için aşağıdaki adımları uygulayın.
Bunu yapabilmek için:
- Uygulamanızın ayarlar sayfasındaki bir düğme gibi gizlilik seçenekleri formunu tetikleyebilecek bir kullanıcı arayüzü öğesi uygulayın.
- İşlem tamamlandığında, gizlilik seçenekleri formunu sunabilecek kullanıcı arayüzü öğesinin gösterilip gösterilmeyeceğini belirlemek için
privacyOptionsRequirementStatus()
işaretini işaretleyin.loadAndShowConsentFormIfRequired()
- Kullanıcı arayüzü öğenizle etkileşimde bulunan bir kullanıcı, gizlilik seçeneklerini dilediği zaman güncelleyebilmesi için formu göstermek üzere
showPrivacyOptionsForm()
numaralı telefonu arayın.
Aşağıdaki örnekte, MenuItem
adresinden gizlilik seçenekleri formunun nasıl sunulacağı gösterilmektedir.
Java
private final ConsentInformation consentInformation;
// Show a privacy options button if required.
public boolean isPrivacyOptionsRequired() {
return consentInformation.getPrivacyOptionsRequirementStatus()
== PrivacyOptionsRequirementStatus.REQUIRED;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
// ...
consentInformation = UserMessagingPlatform.getConsentInformation(this);
consentInformation.requestConsentInfoUpdate(
this,
params,
(OnConsentInfoUpdateSuccessListener) () -> {
UserMessagingPlatform.loadAndShowConsentFormIfRequired(
this,
(OnConsentFormDismissedListener) loadAndShowError -> {
// ...
// Consent has been gathered.
if (isPrivacyOptionsRequired()) {
// Regenerate the options menu to include a privacy setting.
invalidateOptionsMenu();
}
}
)
}
// ...
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.action_menu, menu);
MenuItem moreMenu = menu.findItem(R.id.action_more);
moreMenu.setVisible(isPrivacyOptionsRequired());
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// ...
popup.setOnMenuItemClickListener(
popupMenuItem -> {
if (popupMenuItem.getItemId() == R.id.privacy_settings) {
// Present the privacy options form when a user interacts with
// the privacy settings button.
UserMessagingPlatform.showPrivacyOptionsForm(
this,
formError -> {
if (formError != null) {
// Handle the error.
}
}
);
return true;
}
return false;
});
return super.onOptionsItemSelected(item);
}
Kotlin
private val consentInformation: ConsentInformation =
UserMessagingPlatform.getConsentInformation(context)
// Show a privacy options button if required.
val isPrivacyOptionsRequired: Boolean
get() =
consentInformation.privacyOptionsRequirementStatus ==
ConsentInformation.PrivacyOptionsRequirementStatus.REQUIRED
override fun onCreate(savedInstanceState: Bundle?) {
...
consentInformation = UserMessagingPlatform.getConsentInformation(this)
consentInformation.requestConsentInfoUpdate(
this,
params,
ConsentInformation.OnConsentInfoUpdateSuccessListener {
UserMessagingPlatform.loadAndShowConsentFormIfRequired(
this@MainActivity,
ConsentForm.OnConsentFormDismissedListener {
// ...
// Consent has been gathered.
if (isPrivacyOptionsRequired) {
// Regenerate the options menu to include a privacy setting.
invalidateOptionsMenu();
}
}
)
}
// ...
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.action_menu, menu)
menu?.findItem(R.id.action_more)?.apply {
isVisible = isPrivacyOptionsRequired
}
return super.onCreateOptionsMenu(menu)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
// ...
popup.setOnMenuItemClickListener { popupMenuItem ->
when (popupMenuItem.itemId) {
R.id.privacy_settings -> {
// Present the privacy options form when a user interacts with
// the privacy settings button.
UserMessagingPlatform.showPrivacyOptionsForm(this) { formError ->
formError?.let {
// Handle the error.
}
}
true
}
else -> false
}
}
return super.onOptionsItemSelected(item)
}
Test
Uygulamanız geliştirme aşamasındayken entegrasyonu test etmek isterseniz test cihazınızı programatik olarak kaydetmek için bu adımları uygulayın. Uygulamanızı yayınlamadan önce bu test cihazı kimliklerini ayarlayan kodu kaldırdığınızdan emin olun.
-
requestConsentInfoUpdate()
numaralı telefonu arayın. Günlük çıktısında, cihaz kimliğinizi ve test cihazı olarak nasıl ekleyeceğinizi gösteren aşağıdaki örneğe benzer bir mesaj olup olmadığını kontrol edin:
Use new ConsentDebugSettings.Builder().addTestDeviceHashedId("33BE2250B43518CCDA7DE426D04EE231") to set this as a debug device.
Test cihazı kimliğinizi panonuza kopyalayın.
Kodunuzu, test cihazı kimliklerinizin listesini ayarlayacak
ConsentDebugSettings.Builder().addTestDeviceHashedId()
şekilde değiştirin.Java
ConsentDebugSettings debugSettings = new ConsentDebugSettings.Builder(this) .addTestDeviceHashedId("TEST-DEVICE-HASHED-ID") .build(); ConsentRequestParameters params = new ConsentRequestParameters .Builder() .setConsentDebugSettings(debugSettings) .build(); consentInformation = UserMessagingPlatform.getConsentInformation(this); // Include the ConsentRequestParameters in your consent request. consentInformation.requestConsentInfoUpdate( this, params, ... );
Kotlin
val debugSettings = ConsentDebugSettings.Builder(this) .addTestDeviceHashedId("TEST-DEVICE-HASHED-ID") .build() val params = ConsentRequestParameters .Builder() .setConsentDebugSettings(debugSettings) .build() consentInformation = UserMessagingPlatform.getConsentInformation(this) // Include the ConsentRequestParameters in your consent request. consentInformation.requestConsentInfoUpdate( this, params, ... )
Coğrafi konumu zorunlu kılın
UMP SDK'sı, the setDebugGeography()
method which takes a DebugGeography
on ConsentDebugSettings.Builder
kullanılarak cihaz AEA veya Birleşik Krallık'ta bulunuyormuş gibi uygulamanızın davranışını test edebileceğiniz bir yöntem sunar. Hata ayıklama ayarlarının yalnızca test cihazlarında çalıştığını unutmayın.
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);
// Include the ConsentRequestParameters in your consent request.
consentInformation.requestConsentInfoUpdate(
this,
params,
...
);
Kotlin
val debugSettings = ConsentDebugSettings.Builder(this)
.setDebugGeography(ConsentDebugSettings.DebugGeography.DEBUG_GEOGRAPHY_EEA)
.addTestDeviceHashedId("TEST-DEVICE-HASHED-ID")
.build()
val params = ConsentRequestParameters
.Builder()
.setConsentDebugSettings(debugSettings)
.build()
consentInformation = UserMessagingPlatform.getConsentInformation(this)
// Include the ConsentRequestParameters in your consent request.
consentInformation.requestConsentInfoUpdate(
this,
params,
...
)
İzin durumunu sıfırla
Uygulamanızı UMP SDK ile test ederken bir kullanıcının ilk yükleme deneyimini simüle edebilmek için SDK'nın durumunu sıfırlamayı yararlı bulabilirsiniz.
SDK, bunun için reset()
yöntemini sunar.
Java
consentInformation.reset();
Kotlin
consentInformation.reset()
GitHub'daki örnekler
UMP SDK entegrasyon örnekleri: Java | Kotlin