Unity の動画リワード手動ロード実装

ironSource SDK の動画リワード広告は自動ロードだけでなく、手動ロードに設定することもできます。これを行うには、SDK の初期化の前にセッション全体のロードモードを設定する必要があります。これは、ironSource SDK 7.2.0+(ベータ 7.1.13 Android )からサポートされています。

ステップ1:動画リワード手動ロードイベント実装

ironSource Unity Plugin は広告のアベイラビリティステータスを通知するイベントを発火します。これらのイベントは動画リワード手動ロードを実装することでトリガーされる様になります。

こちらで解説されている動画リワードのイベントに加えて、手動ロード関連のイベントを以下のコード例に従って登録します。

// Add AdInfo Rewarded Video Events
IronSourceRewardedVideoEvents.onAdReadyEvent += RewardedVideoOnAdReadyEvent;
IronSourceRewardedVideoEvents.onAdLoadFailedEvent += RewardedVideoOnAdLoadFailedEvent;
IronSourceRewardedVideoEvents.onAdOpenedEvent += RewardedVideoOnAdOpenedEvent;
IronSourceRewardedVideoEvents.onAdClosedEvent += RewardedVideoOnAdClosedEvent;
IronSourceRewardedVideoEvents.onAdShowFailedEvent += RewardedVideoOnAdShowFailedEvent;
IronSourceRewardedVideoEvents.onAdRewardedEvent += RewardedVideoOnAdRewardedEvent;
IronSourceRewardedVideoEvents.onAdClickedEvent += RewardedVideoOnAdClickedEvent;

プラグインは、以下にリストされている全ての発生しうるイベントをリスナーに通知します:

/************* RewardedVideo AdInfo Delegates *************/
// Indicates that the Rewarded video ad was loaded successfully. 
// AdInfo parameter includes information about the loaded ad
void RewardedVideoOnAdReadyEvent(IronSourceAdInfo adInfo) {}
 
// Indicates that the Rewarded video ad failed to be loaded 
void RewardedVideoOnAdLoadFailedEvent(IronSourceError error) {}

// The Rewarded Video ad view has opened. Your activity will loose focus. 
void RewardedVideoOnAdOpenedEvent(IronSourceAdInfo adInfo){}

// The Rewarded Video ad view is about to be closed. Your activity will regain its focus. 
void RewardedVideoOnAdClosedEvent(IronSourceAdInfo 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.
void RewardedVideoOnAdRewardedEvent(IronSourcePlacement placement, IronSourceAdInfo adInfo){}

// The rewarded video ad was failed to show.
void RewardedVideoOnAdShowFailedEvent(IronSourceError error, IronSourceAdInfo 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. 
void RewardedVideoOnAdClickedEvent(IronSourcePlacement placement, IronSourceAdInfo adInfo){}

ステップ2:動画リワード手動ロード設定

ironSource SDK を初期化する前に、動画リワード広告のロードモードを設定してください。この設定はセッション中継続します。

IronSource.Agent.setManualLoadRewardedVideo(bool isRewardedVideoManualAPI);

ステップ3:手動で動画リワード広告をロードする

ロードプロセスには時間がかかる場合があるため、ユーザーに表示する前に動画リワード広告をリクエストしてください。次の API を使用して広告をロードします。

IronSource.Agent.loadManualRewardedVideo();

完了!
ロードモードの手動モード設定が完了したら、こちらのガイドに従って動画リワードの実装を完了してください。