お客様は、Google の EU ユーザーの同意ポリシーに基づき、英国だけでなく欧州経済領域(EEA)のユーザーに特定の情報を開示し、Cookie などのローカル ストレージを使用することを法的に義務付けられている場合、および個人データ(AdID など)を使用して広告を配信する場合、ユーザーの同意を得る必要があります。このポリシーには、EU の e プライバシー指令と一般データ保護規則(GDPR)の要件が反映されています。
Google は、パブリッシャーがこのポリシーで定められた義務を遂行できるようサポートするため、User Messaging Platform(UMP)SDK を提供しています。更新された UMP SDK では、最新の IAB 標準がサポートされています。これらの構成はすべて、 AdMob プライバシーとメッセージで簡単に処理できるようになりました。
Prerequisites
- スタートガイドを完了している。
- AdMob アカウントの [プライバシーとメッセージ] タブでメッセージを設定していること。詳しくは、 プライバシーとメッセージについて、
- GDPR 関連の要件に取り組んでいる場合は、 IAB の要件が EU ユーザー向け同意メッセージに与える影響をご覧ください。
ユーザー メッセージの種類
サポートされているメッセージの一覧については、 ユーザー メッセージの種類 をご覧ください。各メッセージ タイプを実装する具体的な手順については、左側のナビゲーション バーをご覧ください。
SDK をインポートする
CocoaPods(推奨)
UMP SDK は Google Mobile Ads SDK 7.64.0 以降の Google Mobile Ads SDK Pod の依存関係として含まれています。
iOS プロジェクトに SDK を簡単にインポートするには、CocoaPods を使う方法がおすすめです。プロジェクトの Podfile を開き、アプリのターゲットに次の行を追加します。
pod 'Google-Mobile-Ads-SDK'
そのうえで、次のコマンドを実行します。
pod install --repo-update
CocoaPods を初めてご利用の場合は、CocoaPods の使用に関する記事で Podfile の作成方法と使用方法をご確認ください。
手動ダウンロード
SDK をインポートする別の方法は、手動で行うことです。
次に、フレームワークを Xcode プロジェクトにドラッグし、[Copy items if needed] を選択します。
その後、次を使用して、必要なファイルにフレームワークを含めることができます。
Swift
import UserMessagingPlatform
Objective-C
#include <UserMessagingPlatform/UserMessagingPlatform.h>
Info.plist を更新する
アプリ ID を見つける アプリ ID をInfo.plist
に追加します。
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy</string>
メッセージを表示する必要があるかどうかを判断する
フォームを読み込む前に requestConsentInfoUpdateWithParameters:completionHandler:
を使用して、アプリの起動ごとにユーザーの同意情報の更新をリクエストする必要があります。これにより、ユーザーがまだ同意していない場合またはユーザーの同意の有効期限が切れている場合に、同意を提示する必要があるかどうかを判断できます。
アプリ起動時のステータスを確認する方法の例を次に示します。
Swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Create a UMPRequestParameters object. let parameters = UMPRequestParameters() // Set tag for under age of consent. Here false means users are not under age. parameters.tagForUnderAgeOfConsent = false // Request an update to the consent information. UMPConsentInformation.sharedInstance.requestConsentInfoUpdate( with: parameters, completionHandler: { error in if error != nil { // Handle the error. } else { // The consent information state was updated. // You are now ready to check if a form is // available. } }) }
Objective-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Create a UMPRequestParameters object. UMPRequestParameters *parameters = [[UMPRequestParameters alloc] init]; // Set tag for under age of consent. Here NO means users are not under age. parameters.tagForUnderAgeOfConsent = NO; // Request an update to the consent information. [UMPConsentInformation.sharedInstance requestConsentInfoUpdateWithParameters:parameters completionHandler:^(NSError *_Nullable error) { if (error) { // Handle the error. } else { // The consent information state was updated. // You are now ready to check if a form is // available. } }]; }
利用可能な場合にフォームを読み込む
フォームを表示する前に、フォームが利用可能かどうかを判断する必要があります。このフォームを利用できないのは、ユーザーが制限付きの広告トラッキングを有効にしているか、「同意年齢に満たない」としてタグ付けされている場合です。
フォームが利用可能かどうかを確認するには、先ほど作成したthe formStatus
property on the UMPConsentInformation
instance を使用します。
次に、ラッパー メソッドを追加して、フォームを読み込みます。
Swift
// Request an update to the consent information. UMPConsentInformation.sharedInstance.requestConsentInfoUpdate( withParameters: parameters, completionHandler: { [self] error in // The consent information has updated. if error != nil { // Handle the error. } else { // The consent information state was updated. // You are now ready to see if a form is available. let formStatus = UMPConsentInformation.sharedInstance.formStatus if formStatus == UMPFormStatus.available { loadForm() } } }) ... func loadForm() { }
Objective-C
// Request an update to the consent information. [UMPConsentInformation.sharedInstance requestConsentInfoUpdateWithParameters:parameters completionHandler:^(NSError* _Nullable error) { // The consent information has updated. if (error) { // Handle the error. } else { // The consent information state was updated. // You are now ready to see if a form is available. UMPFormStatus formStatus = UMPConsentInformation.sharedInstance .formStatus; if (formStatus == UMPFormStatusAvailable) { [self loadForm]; } } }]; ... - (void) loadForm { }
フォームを読み込むには、 the static loadWithCompletionHandler:
method on the UMPConsentForm
classを使用します。
Swift
func loadForm() { // Loads a consent form. Must be called on the main thread. UMPConsentForm.load( withCompletionHandler: { form, loadError in if loadError != nil { // Handle the error } else { // Present the form } }) }
Objective-C
- (void)loadForm { [UMPConsentForm loadWithCompletionHandler:^(UMPConsentForm *form, NSError *loadError) { if (loadError) { // Handle the error } else { // Present the form } }]; }
必要に応じてフォームを提示する
フォームが利用可能であることを確認して読み込みが完了したら、UMPConsentForm
インスタンスのpresentFromViewController:completionHandler:
メソッドを使用してフォームを提示します。
前述のUMPConsentInformation
オブジェクトを使用してconsent status を確認し、loadForm
メソッドを更新します。
Swift
func loadForm() { UMPConsentForm.load(withCompletionHandler: { form, loadError in if loadError != nil { // Handle the error. } else { // Present the form. You can also hold on to the reference to present // later. if UMPConsentInformation.sharedInstance.consentStatus == UMPConsentStatus.required { form?.present( from: self, completionHandler: { dismissError in if UMPConsentInformation.sharedInstance.consentStatus == UMPConsentStatus.obtained { // App can start requesting ads. } // Handle dismissal by reloading form. loadForm(); }) } else { // Keep the form available for changes to user consent. } } }) }
Objective-C
- (void)loadForm { [UMPConsentForm loadWithCompletionHandler:^(UMPConsentForm *form, NSError *loadError) { if (loadError) { // Handle the error. } else { // Present the form. You can also hold on to the reference to present // later. if (UMPConsentInformation.sharedInstance.consentStatus == UMPConsentStatusRequired) { [form presentFromViewController:self completionHandler:^(NSError *_Nullable dismissError) { if (UMPConsentInformation.sharedInstance.consentStatus == UMPConsentStatusObtained) { // App can start requesting ads. } // Handle dismissal by reloading form. [self loadForm]; }]; } else { // Keep the form available for changes to user consent. } } }]; }
ユーザーが選択を行うかフォームを拒否した後になんらかのアクションを行う必要がある場合は、そのロジックをフォームの完了ハンドラまたはコールバックに配置します。
テスト
地域を強制的に適用する
UMP SDK では、 the debugGeography
property of type UMPDebugGeography
on UMPDebugSettings
を使用して、デバイスが EEA または英国にあるかのようにアプリの動作をテストできます。
デバッグ機能を使用するには、アプリのデバッグ設定でテスト用デバイスのハッシュ ID を指定する必要があります。この値を設定せずにrequestConsentInfoUpdateWithParameters:completionHandler:
を呼び出すと、実行時に必要な ID ハッシュがログに記録されます。
Swift
let parameters = UMPRequestParameters() let debugSettings = UMPDebugSettings() debugSettings.testDeviceIdentifiers = ["TEST-DEVICE-HASHED-ID"] debugSettings.geography = UMPDebugGeography.EEA parameters.debugSettings = debugSettings 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; [UMPConsentInformation.sharedInstance requestConsentInfoUpdateWithParameters:parameters completionHandler:^(NSError *_Nullable error){ ... }];
UMPDebugGeography
を使用すると、次のいずれかのオプションに地域を強制的に適用できます。
デバッグ地域 | 説明 |
---|---|
UMPDebugGeographyDisabled |
地域デバッグが無効になっています。 |
UMPDebugGeographyEEA |
デバッグ用デバイスで、地域が EEA として表示されます。 |
UMPDebugGeographyNotEEA |
デバッグ用デバイスで、地域が EEA として表示されません。 |
デバッグ設定はテスト用デバイスでのみ機能します。エミュレータはデフォルトでテストが有効になっているため、デバイス ID リストに追加する必要はありません。
同意ステータスをリセットする
UMP SDK でアプリをテストする際、ユーザーの初回インストール エクスペリエンスをシミュレーションできるように、SDK の状態をリセットすると便利な場合があります。SDK には、これを行う reset
メソッドが用意されています。
Swift
UMPConsentInformation.sharedInstance.reset()
Objective-C
[UMPConsentInformation.sharedInstance reset];
UMP SDK をプロジェクトから完全に削除する場合は、 reset
も呼び出す必要があります。