Başlayın

Google AB Kullanıcı Rızası Politikası uyarınca, Avrupa Ekonomik Alanı (AEA) ve Birleşik Krallık'taki 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 verilerin (AdID) reklam yayınlamak amacıyla kullanılması 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 şartları yerine getirmeleri konusunda desteklemek amacıyla 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 hepsi, Interactive Media Ads gizlilik ve mesajlaşma bölümünden kullanılabilir.

Objective-C veya Swift UMP örnek uygulamalarında, UMP SDK'sı ile çalışan bir IMA uygulaması görebilirsiniz.

Ön koşullar

Mesaj türü oluşturma

mevcut kullanıcı mesajı türlerinden birini kullanarak kullanıcı mesajları oluşturun Ad Manager hesabınızdaki Gizlilik ve mesajlaşma UMP SDK'sı, projenizde ayarlanan Interactive Media Ads Uygulama Kimliği'nden oluşturulan bir kullanıcı mesajını göstermeye çalışır. Uygulamanız için herhangi bir mesaj yapılandırılmamışsa SDK hata döndürür.

Daha fazla bilgi için Gizlilik ve mesajlaşma hakkında

SDK'yı içe aktarma

UMP SDK'sı, IMA SDK'nın bağımlılığı olarak dahil edilmediğinden bunu sizin açıkça eklemeniz gerekir.

CocoaPods (tercih edilen)

SDK'yı bir iOS projesine aktarmanın en kolay yolu CocoaPods'u kullanmaktır. Projenizin Podfile'ını açın ve bu satırı uygulamanızın hedefine ekleyin:

pod 'GoogleUserMessagingPlatform'

Ardından aşağıdaki komutu çalıştırın:

pod install --repo-update

CocoaPods'u kullanmaya yeni başladıysanız Podfile dosyaları oluşturma ve kullanma ile ilgili ayrıntılar için CocoaPods'u kullanma bölümüne bakın.

Swift Paket Yöneticisi

UMP SDK'sı, Swift Package Manager'ı da destekler. Swift paketini içe aktarmak için aşağıdaki adımları uygulayın.

  1. Xcode'da Dosya > Paket Ekle... seçeneğine giderek UMP SDK Swift Paketini yükleyin.

  2. Görüntülenen istemde, UMP SDK Swift Package GitHub deposunu arayın:

    https://github.com/googleads/swift-package-manager-google-user-messaging-platform.git
    
  3. Kullanmak istediğiniz UMP SDK Swift Paketi sürümünü seçin. Yeni projeler için Bir Sonraki Ana Sürüm'ü kullanmanızı öneririz.

Daha sonra Xcode, paket bağımlılıklarınızı çözümler ve bunları arka planda indirir. Paket bağımlılıkları ekleme hakkında daha ayrıntılı bilgi için Apple'ın makalesine bakın.

requestConsentInfoUpdateWithParameters:completionHandler:kullanarak her uygulama lansmanında kullanıcının rıza bilgilerinin güncellenmesini istemelisiniz. Bu sayede, kullanıcınız henüz yapmadıysa veya izninin süresi dolduysa izin vermesi gerekip gerekmediğini belirleyebilirsiniz.

viewDidLoad() yönteminde UIViewController öğesinin durumunu nasıl kontrol edeceğinize dair bir örneği aşağıda bulabilirsiniz.

Swift

override func viewDidLoad() {
  super.viewDidLoad()

  // Request an update for the consent information.
  UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(with: nil) {
    [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];

  // Request an update for the consent information.
  [UMPConsentInformation.sharedInstance
      requestConsentInfoUpdateWithParameters:nil
          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ükleyin ve gösterin

En güncel izin durumunu aldıktan sonra izin formu yüklemek için sınıfaloadAndPresentIfRequiredFromViewController:completionHandler: UMPConsentForm ulaşın. İzin durumu gerekliyse SDK bir form yükler ve sağlanan view controllerbölümünden hemen gösterir. Form kapatıldıktan sonra completion handler çağrılır . Rıza gerekmiyorsa completion handler ve hemen çağrılır.

Swift

override func viewDidLoad() {
  super.viewDidLoad()

  // Request an update for the consent information.
  UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(with: nil) {
    [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];

  __weak __typeof__(self) weakSelf = self;
  // Request an update for the consent information.
  [UMPConsentInformation.sharedInstance
      requestConsentInfoUpdateWithParameters:nil
          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ı seçim yaptıktan veya formu kapattıktan sonra herhangi bir işlem yapmanız gerekirse bu mantığı formunuzun completion handlerbölümüne yerleştirin.

Reklam isteğinde bulun

Uygulamanızda reklam isteğinde bulunmadan önce, UMPConsentInformation.sharedInstance.canRequestAdsuygulamasını kullanan kullanıcıdan izin alıp almadığınızı kontrol edin. İzin alınırken kontrol edilecek iki yer vardır:

  1. Mevcut oturumda izin alındıktan sonra.
  2. requestConsentInfoUpdateWithParameters:completionHandler:adlı kişiyi aramanızın hemen ardından. Önceki oturumda izin alınmış olabilir. Gecikmeyle ilgili en iyi uygulamalardan biri olarak, geri çağırma işleminin tamamlanmasını beklememenizi öneririz. Böylece, uygulamanız kullanıma sunulduktan hemen sonra reklamları yüklemeye başlayabilirsiniz.

İzin toplama sürecinde bir hata oluşursa yine de reklam isteğinde bulunmanız gerekir. UMP SDK'sı önceki oturumdaki izin durumunu kullanır.

Swift

class ViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()

    // Request an update for the consent information.
    UMPConsentInformation.sharedInstance.requestConsentInfoUpdate(with: nil) {
      [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.startImaSdk()
        }
      }
    }
    
    // Check if you can initialize the IMA 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 {
      startImaSdk()
    }
  }
  
  private func startImaSdk() {
    // Create an IMAAdsLoader instance.
    adsLoader = IMAAdsLoader(settings: nil)

    // TODO: Create an IMAAdDisplayContainer and IMAAdsRequest, then make
    // a request for ads.
  }
}

Objective-C

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  __weak __typeof__(self) weakSelf = self;
  // Request an update for the consent information.
  [UMPConsentInformation.sharedInstance
      requestConsentInfoUpdateWithParameters:nil
          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 startImaSdk];
                  }
                }];
          }];

  // Check if you can initialize the Google IMA 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 startImaSdk];
  }
}

- (void)startImaSdk {
  static dispatch_once_t onceToken;
  dispatch_once(&onceToken, ^{
    // Create an IMAAdsLoader instance.
    self.adsLoader = [[IMAAdsLoader alloc] init];

    // TODO: Create an IMAAdDisplayContainer and IMAAdsRequest, then make
    // a request for ads.
  });
}

Gizlilik seçenekleri

Bazı izin formlarında, kullanıcının istediği zaman iznini değiştirmesi gerekir. Gerekirse gizlilik seçenekleri düğmesi uygulamak için aşağıdaki adımları uygulayın.

Bunu yapabilmek için:

  1. Uygulamanızın ayarlar sayfasındaki bir düğme gibi, gizlilik seçenekleri formunu tetikleyebilecek bir kullanıcı arayüzü öğesi uygulayın.
  2. loadAndPresentIfRequiredFromViewController:completionHandler: Tamamladıktan sonra, gizlilik seçenekleri formunu gösterebilecek kullanıcı arayüzü öğesinin gösterilip gösterilmeyeceğini belirlemek içinprivacyOptionsRequirementStatus kontrol edin.
  3. Bir kullanıcı, kullanıcı arayüzü öğenizle etkileşime geçtiğinde formun gösterilmesi içinpresentPrivacyOptionsFormFromViewController:completionHandler: çağrısı yapın. Böylece kullanıcının gizlilik seçeneklerini istediği zaman güncelleyebilir.

Aşağıdaki örnekte, bir UIBarButtonItem öğesindeki gizlilik seçenekleri formunun nasıl sunulacağı gösterilmektedir.

Swift

@IBOutlet weak var privacySettingsButton: UIBarButtonItem!

var isPrivacyOptionsRequired: Bool {
  return UMPConsentInformation.sharedInstance.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 istiyorsanız test cihazınızı programatik olarak kaydetmek için bu adımları uygulayın. Uygulamanızı yayınlamadan önce bu test cihazı kimliklerini oluşturan kodu kaldırdığınızdan emin olun.

  1. requestConsentInfoUpdateWithParameters:completionHandler:numaralı telefonu arayın.
  2. Günlük çıkışı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:

    <UMP SDK>To enable debug mode for this device, set: UMPDebugSettings.testDeviceIdentifiers = @[2077ef9a63d2b398840261c8221a0c9b]
    
  3. Test cihazınızın kimliğini panoya kopyalayın.

  4. Kodu, test cihazı kimliklerinizin listesini telefonlaUMPDebugSettings().testDeviceIdentifiers gönderecek ş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){
                              ...
    }];
    

Bir coğrafi bölgeyi zorunlu kılın

UMP SDK'sı, the debugGeography property of type UMPDebugGeography on UMPDebugSettingskullanarak cihaz AEA veya Birleşik Krallık'ta bulunuyormuş gibi uygulamanızın davranışını test etmenin bir yolunu 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){
                           ...
}];

Uygulamanızı UMP SDK ile test ederken kullanıcıların ilk yükleme deneyimini simüle edebilmek için SDK'nın durumunu sıfırlamanız faydalı olabilir. SDK, bunu yapmak için reset yöntemini sağlar.

Swift

UMPConsentInformation.sharedInstance.reset()

Objective-C

[UMPConsentInformation.sharedInstance reset];