コンテンツにスキップ

リワード広告

リワード広告の読み込み

リワード広告をロードするには、リワード広告ユニットに対応するMaxRewardedAdオブジェクトのインスタンスを取得し、そのオブジェクトのloadAd()メソッドを呼び出します。 広告の準備が完了した際に通知されるように、MaxRewardedAdListenerを実装します。 これにより、他の広告関連イベントも通知されます。

public class ExampleActivity extends Activity
implements MaxRewardedAdListener
{
private MaxRewardedAd rewardedAd;
private int retryAttempt;
void createRewardedAd()
{
rewardedAd = MaxRewardedAd.getInstance( "«ad-unit-ID»", getApplicationContext() );
rewardedAd.setListener( this );
rewardedAd.loadAd();
}
// MAX Ad Listener
@Override
public void onAdLoaded(final MaxAd maxAd)
{
// Rewarded ad is ready to be shown. rewardedAd.isReady() will now return 'true'
// Reset retry attempt
retryAttempt = 0;
}
@Override
public void onAdLoadFailed(final String adUnitId, final MaxError error)
{
// Rewarded ad failed to load
// AppLovin recommends that you retry with exponentially higher delays up to a maximum delay (in this case 64 seconds)
retryAttempt++;
long delayMillis = TimeUnit.SECONDS.toMillis( (long) Math.pow( 2, Math.min( 6, retryAttempt ) ) );
new Handler().postDelayed( new Runnable()
{
@Override
public void run()
{
rewardedAd.loadAd();
}
}, delayMillis );
}
@Override
public void onAdDisplayFailed(final MaxAd maxAd, final MaxError error)
{
// Rewarded ad failed to display. AppLovin recommends that you load the next ad.
rewardedAd.loadAd();
}
@Override
public void onAdDisplayed(final MaxAd maxAd) {}
@Override
public void onAdClicked(final MaxAd maxAd) {}
@Override
public void onAdHidden(final MaxAd maxAd)
{
// rewarded ad is hidden. Pre-load the next ad
rewardedAd.loadAd();
}
@Override
public void onUserRewarded(final MaxAd maxAd, final MaxReward maxReward)
{
// Rewarded ad was displayed and user should receive the reward
}
}

リワード広告の表示

リワード広告を表示するには、作成したMaxRewardedAdオブジェクトで showAd( this )を呼び出します。

if ( rewardedAd.isReady() )
{
// `this` is the activity that will be used to show the ad
rewardedAd.showAd( this );
}

リワード広告の金額と通貨へのアクセス

リワード額と通貨にアクセスするには、onUserRewarded() コールバックをオーバーライドします。

@Override
public void onUserRewarded(final MaxAd ad, final MaxReward reward)
{
System.out.println( "Rewarded user: " + reward.getAmount() + " " + reward.getLabel() );
}

S2S Rewarded Callbacks

通貨サーバーへのコールバックを受け取ることができます。 設定方法については、MAX S2S Rewarded CallbackAPIガイドをご覧ください。 次に、Edit Ad UnitページにてServer Side Callback URLをアップデートしてください。

リワード広告の金額と通貨の設定

リワードの金額と通貨を設定する方法:

  1. Edit Ad UnitページにてAdd S2S Reward Callbackをクリックします:Ad Type: ☐App Open, ☐Banner, ☐Interstitial, ☐MRec, ☐Native, ☑Rewarded. Add S2S Reward Callback.
  2. Server Side Callback URLReward AmountおよびRewarded Currency Nameを追加します:Ad Type: ☐App Open, ☐Banner, ☐Interstitial, ☐MRec, ☐Native, ☑Rewarded. Hide Callback Settings.Server Side Callback URL form field. Reward Amount form field. Rewarded Currency Name form field. AppLovin Event Key form field.