全般設定

プラットフォームを選択: Android 新規 Android iOS Unity

GADMobileAds クラスは、Google Mobile Ads SDK によって収集される特定の 情報を制御するためのグローバル設定を提供します。

動画広告のボリューム調整

アプリに独自の音量調節機能(音楽や効果音のカスタム音量設定など)が備わっている場合、アプリの音量設定を Google Mobile Ads SDK に開示すれば、動画広告の音量にもアプリ側の音量設定を反映できます。これにより、ユーザーは想定どおりの音量で動画広告を視聴できます。

デバイスのオーディオ出力の音量は、音量ボタンや OS レベルの音量スライダーで制御されるデバイスの音量によって決まります。アプリでは、音声の聞こえ方を独自にコントロールするために、デバイスの音量に対する相対的な音量レベルを独自に調節できます。

アプリ起動時広告、バナー広告、インタースティシャル広告、リワード広告、リワード インタースティシャル広告のフォーマットでは、相対的なアプリ ボリュームを Google Mobile Ads SDKapplicationVolume プロパティを設定することで通知できます。広告の音量設定値の有効範囲は、0.0(無音)から 1.0(デバイスの現在の音量)までです。アプリ側の相対音量設定を SDK に報告するコードは、たとえば次のようになります。

Swift

func viewDidLoad() {
  super.viewDidLoad()
  // Set app volume to be half of the current device volume.
  MobileAds.shared.applicationVolume = 0.5
  ...
}

Objective-C

- (void)viewDidLoad {
  [super viewDidLoad];
  // Set app volume to be half of the current device volume.
  GADMobileAds.sharedInstance.applicationVolume = 0.5;
  ...
}

アプリ起動時広告、バナー広告、インタースティシャル広告、リワード広告、リワード インタースティシャル広告のフォーマットでは、Google Mobile Ads SDKにアプリの音量がミュートになっていることをapplicationMutedプロパティを設定することで通知できます。

Swift

MobileAds.shared.applicationMuted = true

Objective-C

GADMobileAds.sharedInstance.applicationMuted = YES;

デフォルトでは、applicationVolume1(デバイスの現在の音量)に設定され、applicationMutedNO に設定されています。

ネイティブ広告

ミュート設定の制御方法については、 GADVideoOptions をご覧ください。ネイティブ広告では、カスタム音量設定はサポートされていません。

オーディオ セッション

オーディオ セッションでは、アプリの音声動作について、ご自身の意図をシステムに表明できます。オーディオ セッションについて詳しくは、 Apple の Audio Session Programming Guide をご覧ください。 オーディオを管理するには、Google Mobile Ads SDK audioVideoManager プロパティを使用します。

アプリでオーディオを使用しない場合は、これらの API を使用する必要はありません。 Google Mobile Ads SDK オーディオの再生時には、オーディオ セッション カテゴリが自動的に管理されます。アプリでオーディオを再生し、 オーディオの再生方法とタイミングをより細かく制御したい場合は、これらの API を使用できます。Google Mobile Ads SDK

オーディオ セッション カテゴリをご自身の責任で管理する場合は、オーディオ動画管理で audioSessionIsApplicationManaged プロパティに YES を設定します。

オーディオ セッション カテゴリを管理する場合は、 GADAudioVideoManagerDelegate を実装し、オーディオ動画管理で delegate プロパティを設定して、広告動画イベントとオーディオ 再生イベントの通知を有効にする必要があります。そして、Apple の Audio Session Programming Guide に沿って、オーディオ セッション カテゴリを 関連するカテゴリに変更します。

アプリで音楽を再生する場合に、上記の API を使用して推奨される方法を示す簡単なコードサンプルを次に示します。

Swift

func setUp() {
  MobileAds.shared.audioVideoManager.delegate = self
  MobileAds.shared.audioVideoManager.audioSessionIsApplicationManaged = false
}

// MARK: - GADAudioVideoManagerDelegate
func audioVideoManagerWillPlayAudio(_ audioVideoManager: GADAudioVideoManager) {
  // The Google Mobile Ads SDK is notifying your app that it will play audio. You
  // could optionally pause music depending on your apps design.
  MyAppObject.shared.pauseAllMusic()
}

func audioVideoManagerDidStopPlayingAudio(_ audioVideoManager: GADAudioVideoManager) {
  // The Google Mobile Ads SDK is notifying your app that it has stopped playing
  // audio. Depending on your design, you could resume music here.
  MyAppObject.shared.resumeAllMusic()
}

Objective-C

- (void)setUp {
  GADMobileAds.sharedInstance.audioVideoManager.delegate = self;
  GADMobileAds.sharedInstance.audioVideoManager.audioSessionIsApplicationManaged = NO;
}

#pragma mark - GADAudioVideoManagerDelegate

- (void)audioVideoManagerWillPlayAudio:(GADAudioVideoManager *)audioVideoManager {
  // Google Mobile Ads SDK is notifying your app that it will play audio. You
  // could optionally pause music depending on your apps design.
  [MyAppObject.sharedInstance pauseAllMusic];
}

- (void)audioVideoManagerDidStopPlayingAudio:(GADAudioVideoManager *)audioVideoManager {
    // Google Mobile Ads SDK is notifying your app that it has stopped playing
    // audio. Depending on your design, you could resume music here.
  [MyAppObject.sharedInstance resumeAllMusic];
}

クラッシュ レポート

Google Mobile Ads SDK は iOS アプリで発生した例外を調査し、 SDK が原因の場合には記録します。これらの例外は、今後の SDK バージョンで対処されます。

クラッシュ レポートはデフォルトで有効になります。SDK 関連の例外記録を希望されない場合は、disableSDKCrashReporting メソッドを呼び出すことで、この機能を無効にできます。このメソッドは、次のようにアプリの起動時に呼び出すのが最適です。

Swift

import GoogleMobileAds

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

  func application(_ application: UIApplication,
      didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    MobileAds.shared.disableSDKCrashReporting()
    return true
  }
}

Objective-C

@import GoogleMobileAds;

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

  [GADMobileAds disableSDKCrashReporting];
  return YES;
}

@end

アプリに特別な要件がある場合は、オプションの NSUserDefaults gad_has_consent_for_cookiesを設定できます。Google Mobile Ads SDK により 制限付き広告(LTD) が有効にされます(gad_has_consent_for_cookies がゼロに設定されている場合)。

Swift

UserDefaults.standard.set(0, forKey: "gad_has_consent_for_cookies")

Objective-C

NSUserDefaults.standardUserDefaults().setObject(Int(0),
    forKey: "gad_has_consent_for_cookies");