設定

カスタム イベントを使用すると、 サポートされている広告ネットワークのいずれかを選択します。あなたは それには、目的の広告ネットワークにカスタム イベント アダプタを実装し、 統合できます

前提条件

カスタム イベントを作成するには、まず アプリに実装することをおすすめします

管理画面でカスタム イベントを作成する

まずアド マネージャーでカスタム イベントを作成する必要があります UI です。手順については、次をご覧ください: 収益の作成と管理 できます

以下を指定する必要があります。

クラス名

カスタム イベントを実装するクラスの完全修飾名 たとえば、 com.google.ads.mediation.sample.customevent.SampleCustomEvent。おすすめ すべてのカスタム イベント広告に単一のアダプタクラスを使用することをおすすめします。 使用できます。

ラベル

広告ソースを定義する一意の名前。

パラメータ

カスタム イベント アダプタに渡されるオプションの文字列引数。

アダプターを初期化する

Google Mobile Ads SDK が初期化されると initialize() サポートされているすべてのサードパーティ アダプタと、構成済みのカスタム イベントで呼び出される アド マネージャーの管理画面で [アプリ]を選択してくださいこの方法は、 必要なサードパーティ SDK で必要な設定または初期化を実行する 追加します

Java

package com.google.ads.mediation.sample.customevent;

import com.google.android.gms.ads.AdFormat;
import com.google.android.gms.ads.mediation.Adapter;
import com.google.android.gms.ads.mediation.InitializationCompleteCallback;
import com.google.android.gms.ads.mediation.MediationConfiguration;

public class SampleAdNetworkCustomEvent extends Adapter {
  private static final String SAMPLE_AD_UNIT_KEY = "parameter";

  @Override
  public void initialize(Context context,
      InitializationCompleteCallback initializationCompleteCallback,
      List<MediationConfiguration> mediationConfigurations) {
    // This is where you will initialize the SDK that this custom
    // event is built for. Upon finishing the SDK initialization,
    // call the completion handler with success.
    initializationCompleteCallback.onInitializationSucceeded();
  }
}

Kotlin

package com.google.ads.mediation.sample.customevent

import com.google.android.gms.ads.AdFormat
import com.google.android.gms.ads.mediation.Adapter
import com.google.android.gms.ads.mediation.InitializationCompleteCallback
import com.google.android.gms.ads.mediation.MediationConfiguration

class SampleCustomEvent : Adapter() {
  private val SAMPLE_AD_UNIT_KEY = "parameter"

  override fun initialize(
    context: Context,
    initializationCompleteCallback: InitializationCompleteCallback,
    mediationConfigurations: List<MediationConfiguration>
  ) {
    // This is where you will initialize the SDK that this custom
    // event is built for. Upon finishing the SDK initialization,
    // call the completion handler with success.
    initializationCompleteCallback.onInitializationSucceeded()
  }
}

バージョン番号を報告する

すべてのカスタム イベントは、Google Mobile Ads SDK に カスタム イベント アダプタ自体とサードパーティ SDK のバージョンを カスタム イベント インターフェースを指定します。バージョンは、 VersionInfo オブジェクト:

Java

package com.google.ads.mediation.sample.customevent;

public class SampleCustomEvent extends Adapter {

  @Override
  public VersionInfo getVersionInfo() {
    String versionString = new VersionInfo(1, 2, 3);
    String[] splits = versionString.split("\\.");

    if (splits.length >= 4) {
      int major = Integer.parseInt(splits[0]);
      int minor = Integer.parseInt(splits[1]);
      int micro = Integer.parseInt(splits[2]) * 100 + Integer.parseInt(splits[3]);
      return new VersionInfo(major, minor, micro);
    }

    return new VersionInfo(0, 0, 0);
  }

  @Override
  public VersionInfo getSDKVersionInfo() {
    String versionString = SampleAdRequest.getSDKVersion();
    String[] splits = versionString.split("\\.");

    if (splits.length >= 3) {
      int major = Integer.parseInt(splits[0]);
      int minor = Integer.parseInt(splits[1]);
      int micro = Integer.parseInt(splits[2]);
      return new VersionInfo(major, minor, micro);
    }

    return new VersionInfo(0, 0, 0);
  }
}

Kotlin

package com.google.ads.mediation.sample.customevent

class SampleCustomEvent : Adapter() {
  override fun getVersionInfo(): VersionInfo {
    val versionString = VersionInfo(1,2,3).toString()
    val splits: List<String> = versionString.split("\\.")

    if (splits.count() >= 4) {
      val major = splits[0].toInt()
      val minor = splits[1].toInt()
      val micro = (splits[2].toInt() * 100) + splits[3].toInt()
      return VersionInfo(major, minor, micro)
    }

    return VersionInfo(0, 0, 0)
  }

  override fun getSDKVersionInfo(): VersionInfo {
    val versionString = VersionInfo(1,2,3).toString()
    val splits: List<String> = versionString.split("\\.")

    if (splits.count() >= 3) {
      val major = splits[0].toInt()
      val minor = splits[1].toInt()
      val micro = splits[2].toInt()
      return VersionInfo(major, minor, micro)
    }

    return VersionInfo(0, 0, 0)
  }
}

広告をリクエスト

広告をリクエストするには、広告フォーマットごとの手順をご覧ください。