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 kişisel verileri (AdID gibi) reklam yayınlamak amacıyla 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 şartları 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 bu yapılandırmaların tamamı, AdMob gizlilik ve mesajlaşmada rahatça işlenebilir.
Ön koşullar
- Başlangıç kılavuzunu tamamlayın
- GDPR ile ilgili şartlar üzerinde çalışıyorsanız şu makaleyi okuyun:IAB şartları AB kullanıcı rızası alma mesajlarını nasıl etkiler?
Mesaj türü oluşturma
Kullanılabilir kullanıcı mesajı türlerinden birini kullanarak AdMob hesabınızın Gizlilik ve mesajlaşma sekmesinden kullanarak kullanıcı mesajları oluşturun. UMP SDK'sı, projenizde ayarlanan AdMob Uygulama Kimliği'nden 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.
Daha fazla bilgi için Gizlilik ve mesajlaşma hakkında başlıklı makaleyi inceleyin.
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 bir 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 Pod dosyaları oluşturma ve kullanma ile ilgili ayrıntılar için CocoaPods'u kullanma bölümüne bakın.
Manuel indirme
SDK'yı içe aktarmanın diğer yolu bu işlemi manuel olarak yapmaktır.
Ardından, çerçeveyi Xcode projenize sürükleyin ve Gerekirse öğeleri kopyala'yı seçtiğinizden emin olun.
Ardından, çerçeveyi ihtiyacınız olan herhangi bir dosyaya ekleyebilirsiniz:
Swift
import UserMessagingPlatform
Objective-C
#include <UserMessagingPlatform/UserMessagingPlatform.h>
Rıza bilgisi isteği
requestConsentInfoUpdateWithParameters:completionHandler:
kullanarak her uygulama başlatmada 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 dolup dolmadığını belirler.
viewDidLoad()
yönteminde bir UIViewController
durumunda durumu nasıl kontrol edeceğinize dair bir örneği aşağıda bulabilirsiniz.
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 izin formu yükleme ve 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çin sınıfıUMPConsentForm
loadAndPresentIfRequiredFromViewController:completionHandler:
arayın. İzin durumu gerekliyse SDK bir form yükler ve sağlanan view controllerformdan hemen sunar. Form kapatıldıktan sonra completion handler
çağrı yapılır. İzin gerekmiyorsa completion handler
çağrılanı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 handlerkonumuna yerleştirin.
Reklam isteğinde bulun
Uygulamanızda reklam isteğinde bulunmadan ö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:
- Mevcut oturumda izin alındıktan sonra.
-
requestConsentInfoUpdateWithParameters:completionHandler:
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 deneyebilirsiniz. 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 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) {
[self startGoogleMobileAdsSDK];
}
}
- (void)startGoogleMobileAdsSDK {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// Initialize the Google Mobile Ads SDK.
[GADMobileAds.sharedInstance startWithCompletionHandler:nil];
// TODO: Request an ad.
// [GADInterstitialAd loadWithAdUnitID...];
});
}
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.
-
loadAndPresentIfRequiredFromViewController:completionHandler:
Tamamlandıktan sonra, gizlilik seçenekleri formunu sunabilecek kullanıcı arayüzü öğesinin görüntülenip görüntülenmeyeceğini belirlemek içinprivacyOptionsRequirementStatus
öğesini işaretleyin. - Bir kullanıcı, kullanıcı arayüzü öğenizle etkileşim kurduğunda gizlilik seçeneklerini dilediği zaman güncelleyebilmesi için formu göstermek üzere
presentPrivacyOptionsFormFromViewController:completionHandler:
numaralı telefonu arayın.
Aşağıdaki örnekte, bir UIBarButtonItem
öğesinden gizlilik seçenekleri formunun nasıl sunulacağı gösterilmektedir.
Swift
@IBOutlet weak var privacySettingsButton: UIBarButtonItem!
var isPrivacyOptionsRequired: Bool {
return UMPConsentInformation.shared.privacyOptionsRequirementStatus == .required
}
override func viewDidLoad() {
// ...
// Request an update for the consent information.
UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(with: parameters) {
// ...
UMPConsentForm.loadAndPresentIfRequired(from: self) {
//...
// Consent has been gathered.
// Show the button if privacy options are required.
self.privacySettingsButton.isEnabled = isPrivacyOptionsRequired
}
}
// ...
}
// Present the privacy options form when a user interacts with the
// privacy settings button.
@IBAction func privacySettingsTapped(_ sender: UIBarButtonItem) {
UMPConsentForm.presentPrivacyOptionsForm(from: self) {
[weak self] formError in
guard let self, let formError else { return }
// Handle the error.
}
}
Objective-C
@interface ViewController ()
@property(weak, nonatomic) IBOutlet UIBarButtonItem *privacySettingsButton;
@end
- (BOOL)isPrivacyOptionsRequired {
return UMPConsentInformation.sharedInstance.privacyOptionsRequirementStatus ==
UMPPrivacyOptionsRequirementStatusRequired;
}
- (void)viewDidLoad {
// ...
__weak __typeof__(self) weakSelf = self;
// Request an update for the consent information.
[UMPConsentInformation.sharedInstance
requestConsentInfoUpdateWithParameters:parameters
completionHandler:^(NSError *_Nullable requestConsentError) {
// ...
[UMPConsentForm loadAndPresentIfRequiredFromViewController:strongSelf
completionHandler:^(NSError *loadAndPresentError) {
// ...
// Consent has been gathered.
// Show the button if privacy options are required.
strongSelf.privacySettingsButton.enabled = isPrivacyOptionsRequired;
}];
}];
}
// Present the privacy options form when a user interacts with your
// privacy settings button.
- (IBAction)privacySettingsTapped:(UIBarButtonItem *)sender {
[UMPConsentForm presentPrivacyOptionsFormFromViewController:self
completionHandler:^(NSError *_Nullable formError) {
if (formError) {
// Handle the error.
}
}];
}
Test
Geliştirme sürecinde, uygulamanızdaki entegrasyonu test etmek isterseniz test cihazınızı programatik olarak kaydetmek için aşağıdaki adımları uygulayın.
-
requestConsentInfoUpdateWithParameters:completionHandler:
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 gibi bir mesaj olup olmadığını kontrol edin:
<UMP SDK>To enable debug mode for this device, set: UMPDebugSettings.testDeviceIdentifiers = @[2077ef9a63d2b398840261c8221a0c9b]
Test cihazı kimliğinizi panonuza kopyalayın.
Kodunuzu değiştirerek, test cihazı kimliklerinizin listesini arayacak
UMPDebugSettings().testDeviceIdentifiers
ve bunları iletecek şekilde değiştirin.
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){
...
}];
Konumu zorunlu kıl
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 edebileceğiniz bir yol sağlar. 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 sunar.
Swift
UMPConsentInformation.sharedInstance.reset()
Objective-C
[UMPConsentInformation.sharedInstance reset];
GitHub'daki örnekler
UMP SDK entegrasyon örnekleri: Swift | Objective-C