Google AB Kullanıcı İzni kapsamında Politika'yı ihlal etmiyorsa Avrupa Ekonomik Alanı'ndaki (AEA) kullanıcılarınıza belirli açıklamalar Birleşik Krallık'ta oturum açıp çerez veya başka yerel depolama alanlarını kullanmak için ve reklam yayınlamak için kişisel verileri (Reklam Kimliği gibi) kullanmak. Bu politika AB eGizlilik Yönergesi ve (Genel Veri Koruma Yönetmeliği)
Google, yayıncıları bu politika kapsamındaki gereksinimleri yerine getirmeleri konusunda desteklemek amacıyla Kullanıcı Mesajlaşma Platformu (UMP) SDK'sı. UMP SDK'sı, en son IAB standartlarına uyun. Bu yapılandırmaların hepsi artık çok kolay AdMob gizlilik ve bahsedeceğim.
Ön koşullar
- Başlangıç kılavuzunu tamamlayın
- Android API düzeyi 21 veya üstü (Android için)
- GDPR ile ilgili şartlar üzerinde çalışıyorsanız IAB şartları AB'yi nasıl etkiler? kullanıcı rızası alma mesajları
Mesaj türü oluşturma
Kullanıcı mesajlarını . kullanılabilir kullanıcı mesajı türleri Gizlilik ve mesajlaşma AdMob hesap. UMP SDK'sı bir AdMob Uygulama Kimliği'nden oluşturulan kullanıcı mesajı birçok yolu vardır. Uygulamanız için herhangi bir mesaj yapılandırılmamışsa SDK, hata döndürür.
Daha fazla bilgi için bkz. . Gizlilik ve mesajlaşma hakkında
SDK'yı yükleyin
Google Mobile Ads (GMA) C++ uygulamasını yükleme adımlarını uygulayın: SDK. UMP C++ SDK, GMA C++ SDK'sına dahildir.
Uygulamanızın AdMob uygulamasını yapılandırdığınızdan emin olun Projedeki ID inceleyin.
Kodunuzda, şunu çağırarak UMP SDK'sını başlatın:
ConsentInfo::GetInstance()
.- Android'de, Google tarafından sağlanan
JNIEnv
veActivity
sınavlarını geçmeniz gerekir NDK'dır. Bunu yalnızcaGetInstance()
numaralı telefonu ilk aradığınızda yapmanız gerekir. - Alternatif olarak, halihazırda Firebase C++
SDK'yı test ederek
GetInstance()
ile ilk arama yaptığınızdafirebase::App
içinde.
#include "firebase/gma/ump.h" namespace ump = ::firebase::gma::ump; // Initialize using a firebase::App void InitializeUserMessagingPlatform(const firebase::App& app) { ump::ConsentInfo* consent_info = ump::ConsentInfo::GetInstance(app); } // Initialize without a firebase::App #ifdef ANDROID void InitializeUserMessagingPlatform(JNIEnv* jni_env, jobject activity) { ump::ConsentInfo* consent_info = ump::ConsentInfo::GetInstance(jni_env, activity); } #else // non-Android void InitializeUserMessagingPlatform() { ump::ConsentInfo* consent_info = ump::ConsentInfo::GetInstance(); } #endif
- Android'de, Google tarafından sağlanan
ConsentInfo::GetInstance()
için yapılan sonraki çağrıların tümü aynı örneği döndürür.
UMP SDK'sını kullanmayı bitirdiyseniz
ConsentInfo
örneği:
void ShutdownUserMessagingPlatform() {
ump::ConsentInfo* consent_info = ump::ConsentInfo::GetInstance();
delete consent_info;
}
Eşzamansız işlemleri izlemek için Future
kullanın
CEVAP
firebase::Future
eşzamansız yöntemin tamamlanma durumunu belirlemeniz için bir yol sunar
çağrısının en iyi yoludur.
Eşzamansız olarak çalışan tüm UMP C++ işlevleri ve yöntem çağrıları
Future
ve ayrıca bir "son sonuç" sağlayın işlevini almak için Future
bu işlemi yapabilirsiniz.
Future
öğesinden sonuç almanın iki yolu vardır:
OnCompletion()
numaralı telefonu arayın, kendi geri çağırma işlevinizi iletmenizi sağlar. Bu işlev, gerekir.Future
öğesininstatus()
öğesini düzenli olarak kontrol edin. durumkFutureStatusPending
yerinekFutureStatusCompleted
olarak değiştiğinde, işlemi tamamlandı.
Eşzamansız işlem tamamlandıktan sonra,
İşlem hatasını almak için Future
öğesinin error()
değeri
girin. Hata kodu 0
(kConsentRequestSuccess
) ise
veya kConsentFormSuccess
),
İşlem başarıyla tamamlandı; yoksa hata kodunu kontrol edin ve
belirlemek için error_message()
.
Geri çağırmayı tamamlama
Aşağıda, tamamlanan geri çağırma için OnCompletion
özelliğinin nasıl kullanılacağına dair bir örnek verilmiştir:
eşzamansız işlem tamamlandığında çağrılır.
void MyApplicationStart() {
// [... other app initialization code ...]
ump::ConsentInfo *consent_info = ump::ConsentInfo::GetInstance();
// See the section below for more information about RequestConsentInfoUpdate.
firebase::Future<void> result = consent_info->RequestConsentInfoUpdate(...);
result.OnCompletion([](const firebase::Future<void>& req_result) {
if (req_result.error() == ump::kConsentRequestSuccess) {
// Operation succeeded. You can now call LoadAndShowConsentFormIfRequired().
} else {
// Operation failed. Check req_result.error_message() for more information.
}
});
}
Döngü yoklamayı güncelle
Bu örnekte, uygulama başlatılırken eşzamansız bir işlem başlatıldıktan sonra sonuçlar, oyunun başka bir yerde kontrol edilmesi kare başına bir kez).
ump::ConsentInfo *g_consent_info = nullptr;
bool g_waiting_for_request = false;
void MyApplicationStart() {
// [... other app initialization code ...]
g_consent_info = ump::ConsentInfo::GetInstance();
// See the section below for more information about RequestConsentInfoUpdate.
g_consent_info->RequestConsentInfoUpdate(...);
g_waiting_for_request = true;
}
// Elsewhere, in the game's update loop, which runs once per frame:
void MyGameUpdateLoop() {
// [... other game logic here ...]
if (g_waiting_for_request) {
// Check whether RequestConsentInfoUpdate() has finished.
// Calling "LastResult" returns the Future for the most recent operation.
firebase::Future<void> result =
g_consent_info->RequestConsentInfoUpdateLastResult();
if (result.status() == firebase::kFutureStatusComplete) {
g_waiting_for_request = false;
if (result.error() == ump::kConsentRequestSuccess) {
// Operation succeeded. You can call LoadAndShowConsentFormIfRequired().
} else {
// Operation failed. Check result.error_message() for more information.
}
}
}
}
firebase::Future
hakkında daha fazla bilgi için Firebase C++ SDK'sına bakın
belgeleri
ve GMA C++ SDK belgelerini inceleyin.
Uygulama kimliğini ekleyin
Uygulama kimliğinizi şurada bulabilirsiniz: . AdMob kullanıcı arayüzü. . Kimliği aşağıdaki kod snippet'i ile:
Rıza bilgisi isteği
Her uygulamada kullanıcının rıza bilgilerinin güncellenmesini istemelisiniz.
RequestConsentInfoUpdate()
kullanarak başlat. Bu, kullanıcıların
Kullanıcı daha önce izin vermediyse izin vermesi gerekip gerekmediğini veya
kullanıcı rızasının geçerlilik süresi sona erdiyse.
#include "firebase/gma/ump.h"
namespace ump = ::firebase::gma::ump;
void MyApplicationStart() {
ump::ConsentInfo* consent_info = ump::ConsentInfo::GetInstance();
// Create a ConsentRequestParameters struct.
ump::ConsentRequestParameters params;
// Set tag for under age of consent. False means users are NOT under age
// of consent.
params.tag_for_under_age_of_consent = false;
consent_info->RequestConsentInfoUpdate(params).OnCompletion(
[](const Future<void>& result) {
if (result.error() != ump::kConsentRequestSuccess) {
LogMessage("Error requesting consent update: %s", result.error_message());
} else {
// Consent status is now available.
}
});
}
Tamamlanma durumunu kontrol etmeyle ilgili bir örnek için yukarıya bakın. güncelleme döngüsünü yeniden çağırmaktır.
Gerekirse bir izin formu yükleyip gösterin
En güncel izin durumunu aldıktan sonra
LoadAndShowConsentFormIfRequired()
şurada:
ConsentInfo
sınıflayın. Öğe
SDK, izin durumu gerekli olduğunda bir form yükleyip anında
kaynak: FormParent
. Future
tamamlandı form kapatıldıktan sonra. İzin gerekmiyorsa Future
tamamlandı çalışılır.
void MyApplicationStart(ump::FormParent parent) {
ump::ConsentInfo* consent_info = ump::ConsentInfo::GetInstance();
// Create a ConsentRequestParameters struct..
ump::ConsentRequestParameters params;
// Set tag for under age of consent. False means users are NOT under age of consent.
params.tag_for_under_age_of_consent = false;
consent_info->RequestConsentInfoUpdate(params).OnCompletion(
[*](const Future<void>& req_result) {
if (req_result.error() != ump::kConsentRequestSuccess) {
// req_result.error() is a kConsentRequestError enum.
LogMessage("Error requesting consent update: %s", req_result.error_message());
} else {
consent_info->LoadAndShowConsentFormIfRequired(parent).OnCompletion(
[*](const Future<void>& form_result) {
if (form_result.error() != ump::kConsentFormSuccess) {
// form_result.error() is a kConsentFormError enum.
LogMessage("Error showing consent form: %s", form_result.error_message());
} else {
// Either the form was shown and completed by the user, or consent was not required.
}
});
}
});
}
Kullanıcı seçim yaptıktan veya kapatıldıktan sonra herhangi bir işlem yapmanız gerekirse
bu mantığı Future
işleyen koda yerleştirin.
LoadAndShowConsentFormIfRequired()
tarafından iade edildi.
Reklam isteğinde bulun
Uygulamanızda reklam isteğinde bulunmadan önce izin alıp almadığınızı kontrol edin
ConsentInfo::GetInstance()‑>CanRequestAds()
kullanan kullanıcıdan. İki tür
izin alınırken kontrol edilecek yerler:
- Mevcut oturumda izin alındıktan sonra.
-
RequestConsentInfoUpdate()
adlı kişiyi aramanızın hemen ardından. Önceki oturumda izin alınmış olabilir. Gecikme olarak en iyi uygulama olarak, geri arama işleminin tamamlanmasını beklememenizi öneririz. Uygulamanız kullanıma sunulduktan hemen sonra reklam yüklemeye başlamanızı öneririz.
İzin alma sürecinde bir hata oluşursa reklam isteğinde bulunmayı deneyin. UMP SDK'sı, Search Ads 360'ta önceki kabul edilir.
Aşağıdaki eksiksiz örnekte güncelleme döngüsü yoklaması kullanılmıştır, ancak ayrıca
Eşzamansız işlemleri izlemek için OnCompletion
geri çağırma. Tekliflerinizi otomatikleştirmek ve optimize etmek için
hangi teknik daha uygun olursa olsun.
#include "firebase/future.h"
#include "firebase/gma/gma.h"
#include "firebase/gma/ump.h"
namespace gma = ::firebase::gma;
namespace ump = ::firebase::gma::ump;
using firebase::Future;
ump::ConsentInfo* g_consent_info = nullptr;
// State variable for tracking the UMP consent flow.
enum { kStart, kRequest, kLoadAndShow, kInitGma, kFinished, kErrorState } g_state = kStart;
bool g_ads_allowed = false;
void MyApplicationStart() {
g_consent_info = ump::ConsentInfo::GetInstance(...);
// Create a ConsentRequestParameters struct..
ump::ConsentRequestParameters params;
// Set tag for under age of consent. False means users are NOT under age of consent.
params.tag_for_under_age_of_consent = false;
g_consent_info->RequestConsentInfoUpdate(params);
// CanRequestAds() can return a cached value from a previous run immediately.
g_ads_allowed = g_consent_info->CanRequestAds();
g_state = kRequest;
}
// This function runs once per frame.
void MyGameUpdateLoop() {
// [... other game logic here ...]
if (g_state == kRequest) {
Future<void> req_result = g_consent_info->RequestConsentInfoUpdateLastResult();
if (req_result.status() == firebase::kFutureStatusComplete) {
g_ads_allowed = g_consent_info->CanRequestAds();
if (req_result.error() == ump::kConsentRequestSuccess) {
// You must provide the FormParent (Android Activity or iOS UIViewController).
ump::FormParent parent = GetMyFormParent();
g_consent_info->LoadAndShowConsentFormIfRequired(parent);
g_state = kLoadAndShow;
} else {
LogMessage("Error requesting consent status: %s", req_result.error_message());
g_state = kErrorState;
}
}
}
if (g_state == kLoadAndShow) {
Future<void> form_result = g_consent_info->LoadAndShowConsentFormIfRequiredLastResult();
if (form_result.status() == firebase::kFutureStatusComplete) {
g_ads_allowed = g_consent_info->CanRequestAds();
if (form_result.error() == ump::kConsentRequestSuccess) {
if (g_ads_allowed) {
// Initialize GMA. This is another asynchronous operation.
firebase::gma::Initialize();
g_state = kInitGma;
} else {
g_state = kFinished;
}
// Optional: shut down the UMP SDK to save memory.
delete g_consent_info;
g_consent_info = nullptr;
} else {
LogMessage("Error displaying consent form: %s", form_result.error_message());
g_state = kErrorState;
}
}
}
if (g_state == kInitGma && g_ads_allowed) {
Future<gma::AdapterInitializationStatus> gma_future = gma::InitializeLastResult();
if (gma_future.status() == firebase::kFutureStatusComplete) {
if (gma_future.error() == gma::kAdErrorCodeNone) {
g_state = kFinished;
// TODO: Request an ad.
} else {
LogMessage("Error initializing GMA: %s", gma_future.error_message());
g_state = kErrorState;
}
}
}
}
Gizlilik seçenekleri
Bazı izin formlarında, kullanıcının istediği zaman iznini değiştirmesi gerekir. Bağlı olun gizlilik seçenekleri düğmesi uygulamak için aşağıdaki adımlara uygulayın.
Bunu yapabilmek için:
- Uygulamanızın ayarlar sayfasındaki bir düğme gibi kullanıcı arayüzü öğesi uygulayın. gizlilik seçenekleri formunu tetikleyebilecek şekilde açıklayabilirsiniz.
- Tamamlandığında
LoadAndShowConsentFormIfRequired()
kontrol edin karar vermek için kullanılangetPrivacyOptionsRequirementStatus()
gizlilik seçenekleri formunu sunabilen kullanıcı arayüzü öğesi. - Bir kullanıcı, UI öğenizle etkileşime geçtiğinde
showPrivacyOptionsForm()
Böylece formu göstererek gizlilik seçeneklerini diledikleri zaman güncelleyebilirler.
Test
Geliştirme sürecinde uygulamanızdaki entegrasyonu test etmek isterseniz bu adımları izleyerek test cihazınızı programlı olarak kaydedin. Etiketinizi kaldırdığınızda uygulamanızı yayınlamadan önce bu test cihazı kimliklerini belirleyen koddur.
-
RequestConsentInfoUpdate()
numaralı telefonu arayın. Aşağıdaki örneğe benzer bir mesaj için günlük çıkışını kontrol edin: cihaz kimliğinizi ve test cihazı olarak nasıl ekleyeceğinizi gösterir:
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]
Test cihazınızın kimliğini panoya kopyalayın.
Kodunuzu şu şekilde değiştirin:
ConsentRequestParameters.debug_settings.debug_device_ids
aramak test cihazı kimliklerinizin listesi.void MyApplicationStart() { ump::ConsentInfo consent_info = ump::ConsentInfo::GetInstance(...); ump::ConsentRequestParameters params; params.tag_for_under_age_of_consent = false; params.debug_settings.debug_device_ids = {"TEST-DEVICE-HASHED-ID"}; consent_info->RequestConsentInfoUpdate(params); }
Bir coğrafi bölgeyi zorunlu kılın
UMP SDK'sı, uygulamanızın davranışını cihaz sanki
AEA veya Birleşik Krallık'ta ConsentRequestParameters.debug_settings.debug_geography
kullanarak bulabilirsiniz. Lütfen
Hata ayıklama ayarları yalnızca test cihazlarında çalışır.
void MyApplicationStart() {
ump::ConsentInfo consent_info = ump::ConsentInfo::GetInstance(...);
ump::ConsentRequestParameters params;
params.tag_for_under_age_of_consent = false;
params.debug_settings.debug_device_ids = {"TEST-DEVICE-HASHED-ID"};
// Geography appears as EEA for debug devices.
params.debug_settings.debug_geography = ump::kConsentDebugGeographyEEA
consent_info->RequestConsentInfoUpdate(params);
}
İzin durumunu sıfırla
Uygulamanızı UMP SDK'sı ile test ederken
kullanıcının ilk yükleme deneyimini simüle edebilmek için SDK durumunu kontrol edin.
SDK, bunu yapmak için Reset()
yöntemini sağlar.
ConsentInfo::GetInstance()->Reset();