LevelPlay Listener と Ad Info の実装
ironSource SDK 7.2.3 から、ネットワーク、セグメント、A/B など、より多くのデータを広告コールバックで受け取ることが可能になりました。
新しい広告ユニットリスナーの実装
AdInfo コールバックを発火する、新しい LevelPlay Listener を実装します。
AdInfo はロードに成功した直近の広告データであり、表示できる広告在庫がない場合に発火するロード失敗のコールバックには含まれません。
データの重複を防ぐため、既存のリスナーの登録を解除することを推奨しています。
動画リワード
IronSource.setLevelPlayRewardedVideoListener(new LevelPlayRewardedVideoListener() {
// Indicates that there's an available ad.
// The adInfo object includes information about the ad that was loaded successfully
// Use this callback instead of onRewardedVideoAvailabilityChanged(true)
@Override
public void onAdAvailable(AdInfo adInfo) {}
// Indicates that no ads are available to be displayed
// Use this callback instead of onRewardedVideoAvailabilityChanged(false)
@Override
public void onAdUnavailable() {}
// The Rewarded Video ad view has opened. Your activity will loose focus
@Override
public void onAdOpened(AdInfo adInfo) {}
// The Rewarded Video ad view is about to be closed. Your activity will regain its focus
@Override
public void onAdClosed(AdInfo adInfo) {}
// The user completed to watch the video, and should be rewarded.
// The placement parameter will include the reward data.
// When using server-to-server callbacks, you may ignore this event and wait for the ironSource server callback
@Override
public void onAdRewarded(Placement placement, AdInfo adInfo) {}
// The rewarded video ad was failed to show
@Override
public void onAdShowFailed(IronSourceError error, AdInfo adInfo) {}
// Invoked when the video ad was clicked.
// This callback is not supported by all networks, and we recommend using it
// only if it's supported by all networks you included in your build
@Override
public void onAdClicked(Placement placement, AdInfo adInfo) {}
});
Note:
RewardedVideoListener から LevelPlayRewardedVideoListener へ実装を更新する場合は、onRewardedVideoAvailabilityChanged の代わりに onAdAvailable と onAdUnavailable を使用してください。
動画リワード手動ロード
IronSource.setLevelPlayRewardedVideoManualListener(new LevelPlayRewardedVideoManualListener() {
// Indicates that the Rewarded video ad was loaded successfully.
// AdInfo parameter includes information about the loaded ad
@Override
public void onAdReady(AdInfo adInfo) {}
// Invoked when the rewarded video failed to load
@Override
public void onAdLoadFailed(IronSourceError error) {}
// The Rewarded Video ad view has opened. Your activity will loose focus
@Override
public void onAdOpened(AdInfo adInfo) {}
// The Rewarded Video ad view is about to be closed. Your activity will regain its focus
@Override
public void onAdClosed(AdInfo adInfo) {}
// The user completed to watch the video, and should be rewarded.
// The placement parameter will include the reward data.
// When using server-to-server callbacks, you may ignore this event and wait for the ironSource server callback
@Override
public void onAdRewarded(Placement placement, AdInfo adInfo) {}
// The rewarded video ad was failed to show
@Override
public void onAdShowFailed(IronSourceError error, AdInfo adInfo) {}
// Invoked when the video ad was clicked.
// This callback is not supported by all networks, and we recommend using it
// only if it's supported by all networks you included in your build
@Override
public void onAdClicked(Placement placement, AdInfo adInfo) {}
});
インタースティシャル
IronSource.setLevelPlayInterstitialListener(new LevelPlayInterstitialListener() {
// Invoked when the interstitial ad was loaded successfully.
// AdInfo parameter includes information about the loaded ad
@Override
public void onAdReady(AdInfo adInfo) {}
// Indicates that the ad failed to be loaded
@Override
public void onAdLoadFailed(IronSourceError error) {}
// Invoked when the Interstitial Ad Unit has opened, and user left the application screen.
// This is the impression indication.
@Override
public void onAdOpened(AdInfo adInfo) {}
// Invoked when the interstitial ad closed and the user went back to the application screen.
@Override
public void onAdClosed(AdInfo adInfo) {}
// Invoked when the ad failed to show
@Override
public void onAdShowFailed(IronSourceError error, AdInfo adInfo) {}
// Invoked when end user clicked on the interstitial ad
@Override
public void onAdClicked(AdInfo adInfo) {}
// Invoked before the interstitial ad was opened, and before the InterstitialOnAdOpenedEvent is reported.
// This callback is not supported by all networks, and we recommend using it only if
// it's supported by all networks you included in your build.
@Override
public void onAdShowSucceeded(AdInfo adInfo) {}
});
バナー
banner.setLevelPlayBannerListener(new LevelPlayBannerListener() {
// Invoked each time a banner was loaded. Either on refresh, or manual load.
// AdInfo parameter includes information about the loaded ad
@Override
public void onAdLoaded(AdInfo adInfo) {}
// Invoked when the banner loading process has failed.
// This callback will be sent both for manual load and refreshed banner failures.
@Override
public void onAdLoadFailed(IronSourceError error) {}
// Invoked when end user clicks on the banner ad
@Override
public void onAdClicked(AdInfo adInfo) {}
// Notifies the presentation of a full screen content following user click
@Override
public void onAdScreenPresented(AdInfo adInfo) {}
// Notifies the presented screen has been dismissed
@Override
public void onAdScreenDismissed(AdInfo adInfo) {}
//Invoked when the user left the app
@Override
public void onAdLeftApplication(AdInfo adInfo) {}
});
Note:
onAdLoaded と onAdLoadFailed コールバックはバナーの手動ロードと自動リフレッシュの両方で発火します。
AdInfo のデータを実装する
AdInfo を含む LevelPlay Listener を実装すると、アプリ内でAdInfo のデータを使用することが出来ます。
AdInfo のデータが利用できない場合、string パラメーターは空の文字列、数字パラメーターは 0 を返します。
IronSource.setLevelPlayListener(LevelPlayInterstitialListener) {
@override
public void onAdReady (AdInfo adInfo)
{
String AdUnit = adInfo.getAdUnit();
String AuctionId = adInfo.getAuctionId();
String AdNetwork = adInfo.getAdNetwork();
String Ab = adInfo.getAb();
String Country = adInfo.getCountry();
String InstanceId = adInfo.getInstanceId();
String InstanceName = adInfo.getInstanceName();
String SegmentName = adInfo.getSegmentName();
Double Revenue = adInfo.getRevenue();
String Precision = adInfo.getPrecision();
String EncryptedCPM = adInfo.getEncryptedCPM();
}
}
Ad Info フィールド
AdInfo オブジェクトが含むパラメーターの説明とデータ型は以下のリストを参照してください:
Parameter Name | Description | Data Type |
auctionId | オークションのユニークID | String |
adUnit | 表示された広告ユニット( Rewarded Video / Interstitial / Banner ) | String |
adNetwork | 広告を表示したアドネットワーク | String |
instanceName | プラットフォームで定義されたアドネットワークインスタンス名。ビディングインスタンスの場合は「 Bidding 」 | String |
instanceId | アドネットワークで使用するID名。instanceID / placement / zone 等 | String |
country | ISO 3166-1 フォーマットの国コード | String |
revenue | インプレッションの収益( USD )。精度は推定値または確定値( precision フィールドの説明を参照) | Double |
precision | revenue フィールドの精度: BID – リアルタイムオークションで入札された収益値( Meta ビディング以外) RATE – パブリッシャーが LevelPlay プラットフォームでインスタンスに設定した金額 CPM – インスタンスの LevelPlay 上での過去のパフォーマンスを元に計算された値 |
String |
ab | LevelPlay プラットフォームで A/B テストが有効な場合、所属するグループ | String |
segmentName | セグメントのメソッドを元に定義されたユーザが所属するセグメント名 | String |
encryptedCPM | Meta Audience Network 広告のみ。Meta Audience Network により Closed Beta として承認されているパブリッシャーへのみ配信される暗号化された CPM | String |