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, yasal olarak gerekli olduğu durumlarda çerez veya başka yerel depolama bilgilerinin kullanımının yanı sıra reklam yayınlamak üzere kişisel verileri (reklam kimliği) kullanma konusunda 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üncellendi. Tüm bu yapılandırmalar artık Ad Manager gizlilik ve mesajlaşmadan rahatça işlenebilir.
Ön koşullar
- Başlangıç kılavuzunu tamamlayın
- GDPR ile ilgili koşullar üzerinde çalışıyorsanız şu makaleyi okuyun: IAB şartları AB kullanıcı rızası alma mesajlarını nasıl etkiler?
Mesaj türü oluşturun
yararlanabilir kullanıcı mesajı türlerinden biriyle kullanıcı mesajları oluşturun Ad Manager hesabınızın Gizlilik ve mesajlaşma sekmesi altında. UMP SDK'sı, projenizde ayarlanan Ad Manager Uygulama Kimliğinden oluşturulan bir 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.
Ayrıntılı bilgi için Gizlilik ve mesajlaşma hakkında.
SDK'yı içe aktarın
CocoaPods (tercih edilen)
UMP SDK'sı, Google Mobile Ads SDK'sı 7.64.0 ile başlayan Google Mobile Ads SDK'sı kapsülünün bağımlılığı olarak dahil edilir.
SDK'yı bir iOS projesine aktarmanın en kolay yolu CocoaPods'u kullanmaktır. Projenizin Podfile dosyasını açın ve şu satırı uygulamanızın hedefine ekleyin:
pod 'Google-Mobile-Ads-SDK'
Ardından aşağıdaki komutu çalıştırın:
pod install --repo-update
CocoaPods'u kullanmaya yeni başladıysanız Podfile dosyası oluşturup kullanmayla ilgili ayrıntılar için CocoaPods'u kullanma bölümünü inceleyin.
Manuel indirme
SDK'yı içe aktarmanın diğer bir yolu bu işlemi manuel olarak yapmaktır.
Ardından, çerçeveyi Xcode projenize sürükleyerek Gerekirse öğeleri kopyala'yı seçin.
Ardından, çerçeveyi ihtiyacınız olan herhangi bir dosyaya aşağıdakileri kullanarak ekleyebilirsiniz:
Swift
import UserMessagingPlatform
Objective-C
#include <UserMessagingPlatform/UserMessagingPlatform.h>
Rıza bilgileri isteği
Her uygulama lansmanında, requestConsentInfoUpdateWithParameters:completionHandler:
kullanarak kullanıcının izin bilgilerinin güncellenmesini istemelisiniz. Bu, kullanıcınızın henüz yapmadıysa izin vermesi gerekip gerekmediğini veya izin süresinin dolduğunu belirler.
Aşağıda, durumu viewDidLoad()
yönteminde UIViewController
üzerinden nasıl kontrol edeceğinizle ilgili bir örnek verilmiştir.
Swift
override func viewDidLoad() {
super.viewDidLoad()
// Create a UMPRequestParameters object.
let parameters = UMPRequestParameters()
// Set tag for under age of consent. false means users are not under age
// of consent.
parameters.tagForUnderAgeOfConsent = false
// Request an update for the consent information.
UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(with: parameters) {
[weak self] requestConsentError in
guard let self else { return }
if let consentError = requestConsentError {
// Consent gathering failed.
return print("Error: \(consentError.localizedDescription)")
}
// TODO: Load and present the consent form.
}
}
Objective-C
- (void)viewDidLoad {
[super viewDidLoad];
// Create a UMPRequestParameters object.
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
// Set tag for under age of consent. NO means users are not under age
// of consent.
parameters.tagForUnderAgeOfConsent = NO;
// Request an update for the consent information.
[UMPConsentInformation.sharedInstance
requestConsentInfoUpdateWithParameters:parameters
completionHandler:^(NSError *_Nullable requestConsentError) {
if (requestConsentError) {
// Consent gathering failed.
NSLog(@"Error: %@", requestConsentError.localizedDescription);
return;
}
// TODO: Load and present the consent form.
}];
}
Gerekirse bir izin formu yükleme ve gösterme
En güncel izin durumunu aldıktan sonra izin formu yüklemek için
UMPConsentForm
sınıfındaloadAndPresentIfRequiredFromViewController:completionHandler:
numaralı telefonu arayın. İzin durumu gerekliyse SDK bir form yükler ve sağlanan view controllerformundan hemen sunar. completion handler
form kapatıldıktan sonra çağrılır. İzin gerekmiyorsa completion handlerhemen çağrılır.
Swift
override func viewDidLoad() {
super.viewDidLoad()
// Create a UMPRequestParameters object.
let parameters = UMPRequestParameters()
// Set tag for under age of consent. false means users are not under age
// of consent.
parameters.tagForUnderAgeOfConsent = false
// Request an update for the consent information.
UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(with: parameters) {
[weak self] requestConsentError in
guard let self else { return }
if let consentError = requestConsentError {
// Consent gathering failed.
return print("Error: \(consentError.localizedDescription)")
}
UMPConsentForm.loadAndPresentIfRequired(from: self) {
[weak self] loadAndPresentError in
guard let self else { return }
if let consentError = loadAndPresentError {
// Consent gathering failed.
return print("Error: \(consentError.localizedDescription)")
}
// Consent has been gathered.
}
}
}
Objective-C
- (void)viewDidLoad {
[super viewDidLoad];
// Create a UMPRequestParameters object.
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
// Set tag for under age of consent. NO means users are not under age
// of consent.
parameters.tagForUnderAgeOfConsent = NO;
__weak __typeof__(self) weakSelf = self;
// Request an update for the consent information.
[UMPConsentInformation.sharedInstance
requestConsentInfoUpdateWithParameters:parameters
completionHandler:^(NSError *_Nullable requestConsentError) {
if (requestConsentError) {
// Consent gathering failed.
NSLog(@"Error: %@", requestConsentError.localizedDescription);
return;
}
__strong __typeof__(self) strongSelf = weakSelf;
if (!strongSelf) {
return;
}
[UMPConsentForm loadAndPresentIfRequiredFromViewController:strongSelf
completionHandler:^(NSError *loadAndPresentError) {
if (loadAndPresentError) {
// Consent gathering failed.
NSLog(@"Error: %@", loadAndPresentError.localizedDescription);
return;
}
// Consent has been gathered.
}];
}];
}
Kullanıcı bir seçim yaptıktan veya formu kapattıktan sonra herhangi bir işlem gerçekleştirmeniz gerekirse bu mantığı formunuzun completion handlerbölümüne yerleştirin.
Reklam isteğinde bulun
Uygulamanızda reklam istemeden önce, UMPConsentInformation.sharedInstance.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 toplandıktan sonra.
-
requestConsentInfoUpdateWithParameters:completionHandler:
numaralı telefonu aradıktan hemen sonra. Önceki oturumda izin alınmış olabilir. Gecikme için en iyi uygulama olarak, uygulamanız kullanıma sunulduktan hemen sonra reklamları yüklemeye başlayabilmeniz için geri çağırmanın tamamlanmasını beklememenizi öneririz.
İzin toplama süreci sırasında bir hata meydana gelirse yine de reklam istemeye çalışmalısınız. UMP SDK'sı, önceki oturumdaki izin durumunu kullanır.
Swift
class ViewController: UIViewController {
// Use a boolean to initialize the Google Mobile Ads SDK and load ads once.
private var isMobileAdsStartCalled = false
override func viewDidLoad() {
super.viewDidLoad()
// Create a UMPRequestParameters object.
let parameters = UMPRequestParameters()
// Set tag for under age of consent. false means users are not under age
// of consent.
parameters.tagForUnderAgeOfConsent = false
// Request an update for the consent information.
UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(with: parameters) {
[weak self] requestConsentError in
guard let self else { return }
if let consentError = requestConsentError {
// Consent gathering failed.
return print("Error: \(consentError.localizedDescription)")
}
UMPConsentForm.loadAndPresentIfRequired(from: self) {
[weak self] loadAndPresentError in
guard let self else { return }
if let consentError = loadAndPresentError {
// Consent gathering failed.
return print("Error: \(consentError.localizedDescription)")
}
// Consent has been gathered.
if UMPConsentInformation.sharedInstance.canRequestAds {
self.startGoogleMobileAdsSDK()
}
}
}
// 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 UMPConsentInformation.sharedInstance.canRequestAds {
startGoogleMobileAdsSDK()
}
}
private func startGoogleMobileAdsSDK() {
DispatchQueue.main.async {
guard !self.isMobileAdsStartCalled else { return }
self.isMobileAdsStartCalled = true
// Initialize the Google Mobile Ads SDK.
GADMobileAds.sharedInstance().start()
// TODO: Request an ad.
// GADInterstitialAd.load(...)
}
}
}
Objective-C
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Create a UMPRequestParameters object.
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
// Set tag for under age of consent. NO means users are not under age
// of consent.
parameters.tagForUnderAgeOfConsent = NO;
__weak __typeof__(self) weakSelf = self;
// Request an update for the consent information.
[UMPConsentInformation.sharedInstance
requestConsentInfoUpdateWithParameters:parameters
completionHandler:^(NSError *_Nullable requestConsentError) {
if (requestConsentError) {
// Consent gathering failed.
NSLog(@"Error: %@", requestConsentError.localizedDescription);
return;
}
__strong __typeof__(self) strongSelf = weakSelf;
if (!strongSelf) {
return;
}
[UMPConsentForm loadAndPresentIfRequiredFromViewController:strongSelf
completionHandler:^(NSError *loadAndPresentError) {
if (loadAndPresentError) {
// Consent gathering failed.
NSLog(@"Error: %@", loadAndPresentError.localizedDescription);
return;
}
// Consent has been gathered.
__strong __typeof__(self) strongSelf = weakSelf;
if (!strongSelf) {
return;
}
if (UMPConsentInformation.sharedInstance.canRequestAds) {
[strongSelf startGoogleMobileAdsSDKOnce];
}
}];
}];
// 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 (UMPConsentInformation.sharedInstance.canRequestAds) {
[self startGoogleMobileAdsSDKOnce];
}
}
- (void)startGoogleMobileAdsSDKOnce {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// Initialize the Google Mobile Ads SDK.
[GADMobileAds.sharedInstance startWithCompletionHandler:nil];
// TODO: Request an ad.
// [GADInterstitialAd loadWithAdUnitID...];
});
}
Test
Uygulamanız geliştirme sürecindeyken entegrasyonu test etmek istiyorsanız test cihazınızı programatik olarak kaydetmek için aşağıdaki adımları izleyin.
-
requestConsentInfoUpdateWithParameters:completionHandler:
numaralı telefonu arayın. Günlük çıktısında aşağıdaki gibi bir mesaj olup olmadığını kontrol edin. Bu mesajda, cihaz kimliğinizi ve test cihazı olarak nasıl ekleyeceğinizi görebilirsiniz:
<UMP SDK>To enable debug mode for this device, set: UMPDebugSettings.testDeviceIdentifiers = @[2077ef9a63d2b398840261c8221a0c9b]
Test cihazı kimliğinizi panonuza kopyalayın.
Kodu çağıracak
UMPDebugSettings().testDeviceIdentifiers
şekilde değiştirin ve test cihazı kimliklerinizin listesini iletin.
Swift
let parameters = UMPRequestParameters()
let debugSettings = UMPDebugSettings()
debugSettings.testDeviceIdentifiers = ["TEST-DEVICE-HASHED-ID"]
parameters.debugSettings = debugSettings
// Include the UMPRequestParameters in your consent request.
UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(
with: parameters,
completionHandler: { error in
...
})
Objective-C
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
debugSettings.testDeviceIdentifiers = @[ @"TEST-DEVICE-HASHED-ID" ];
parameters.debugSettings = debugSettings;
// Include the UMPRequestParameters in your consent request.
[UMPConsentInformation.sharedInstance
requestConsentInfoUpdateWithParameters:parameters
completionHandler:^(NSError *_Nullable error){
...
}];
Coğrafyayı zorunlu kılma
UMP SDK'sı, the debugGeography
property of type UMPDebugGeography
on UMPDebugSettings
kullanarak cihaz AEA veya Birleşik Krallık'ta bulunuyormuş gibi uygulamanızın davranışını test etmenize olanak tanır. Hata ayıklama ayarlarının yalnızca test cihazlarında çalıştığını unutmayın.
Swift
let parameters = UMPRequestParameters()
let debugSettings = UMPDebugSettings()
debugSettings.testDeviceIdentifiers = ["TEST-DEVICE-HASHED-ID"]
debugSettings.geography = .EEA
parameters.debugSettings = debugSettings
// Include the UMPRequestParameters in your consent request.
UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(
with: parameters,
completionHandler: { error in
...
})
Objective-C
UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init];
UMPDebugSettings *debugSettings = [[UMPDebugSettings alloc] init];
debugSettings.testDeviceIdentifiers = @[ @"TEST-DEVICE-HASHED-ID" ];
debugSettings.geography = UMPDebugGeographyEEA;
parameters.debugSettings = debugSettings;
// Include the UMPRequestParameters in your consent request.
[UMPConsentInformation.sharedInstance
requestConsentInfoUpdateWithParameters:parameters
completionHandler:^(NSError *_Nullable error){
...
}];
İ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ı faydalı bulabilirsiniz.
SDK, bunun için reset
yöntemini sağlar.
Swift
UMPConsentInformation.sharedInstance.reset()
Objective-C
[UMPConsentInformation.sharedInstance reset];