My app uses 3 separate rewarded ad video buttons, each offering a different reward.
However, I’m lost as to how to trigger the specific reward depending on which button the user presses.
When I used Admob, I had three separate rewarded ad units that I implemented into my code and had no problems with issuing rewards.
With LevelPlay, you can only have one rewarded ad unit, so I can’t use the Admob method. From reading the documentation, you can use Placements to achieve what I’m after, but i can’t get it working correctly.
I’ve created 3 Placements:
- Item_Store (User can earn 10 coins.)
- Settings (User can get a free power up.)
- Game_Over (User can get a continue.)
I’ve added the PlacementName string to the relevant showRewardedVideo code but I’m stuck after this.
When testing the ads, the test ads play but I can only recieve one reward regardless of which rewarded button I press.
What am I missing so that I can receive the relevant reward based on which reward button is triggered?
void Start()
{
IronSource.Agent.validateIntegration();
IronSource.Agent.init(appKey);
}
void OnEnable()
{
IronSourceEvents.onSdkInitializationCompletedEvent += SDKInitialized;
IronSourceInterstitialEvents.onAdShowFailedEvent += InterstitialOnAdShowFailedEvent;
IronSourceInterstitialEvents.onAdClosedEvent += InterstitialOnAdClosedEvent;
IronSourceRewardedVideoEvents.onAdShowFailedEvent += RewardedVideoOnAdShowFailedEvent;
IronSourceRewardedVideoEvents.onAdClosedEvent += RewardedVideoOnAdClosedEvent;
IronSourceRewardedVideoEvents.onAdRewardedEvent += RewardedVideoOnAdRewardedEvent;
}
void SDKInitialized()
{
LoadBanner();
LoadInterstitial();
LoadRewardedAd();
}
void OnApplicationPause(bool isPaused)
{
IronSource.Agent.onApplicationPause(isPaused);
}
//// Banner Ad ////
public void LoadBanner()
{
IronSource.Agent.loadBanner(IronSourceBannerSize.SMART, IronSourceBannerPosition.BOTTOM);
}
void ShowBanner()
{
IronSource.Agent.displayBanner();
}
public void HideBanner()
{
IronSource.Agent.hideBanner();
}
//// Interstitial Ad /////
public void LoadInterstitial()
{
IronSource.Agent.loadInterstitial();
}
public void ShowInterstitial()
{
if (IronSource.Agent.isInterstitialReady())
{
IronSource.Agent.showInterstitial();
}
}
void InterstitialOnAdShowFailedEvent(IronSourceError ironSourceError, IronSourceAdInfo adInfo)
{
IronSource.Agent.loadInterstitial();
}
void InterstitialOnAdClosedEvent(IronSourceAdInfo adInfo)
{
IronSource.Agent.loadInterstitial();
}
//// Rewarded Ads ////
public void LoadRewardedAd()
{
IronSource.Agent.loadRewardedVideo();
}
public void ShowRewardedAd_10Coins()
{
if (IronSource.Agent.isRewardedVideoAvailable())
{
IronSource.Agent.showRewardedVideo("Item_Store");
}
}
public void ShowRewardedAd_PowerUps()
{
if (IronSource.Agent.isRewardedVideoAvailable())
{
IronSource.Agent.showRewardedVideo("Settings");
}
}
public void ShowRewardedAd_Continue()
{
if (IronSource.Agent.isRewardedVideoAvailable())
{
IronSource.Agent.showRewardedVideo("Game_Over");
}
}
void RewardedVideoOnAdClosedEvent(IronSourceAdInfo adInfo)
{
LoadRewardedAd();
}
void RewardedVideoOnAdShowFailedEvent(IronSourceError error, IronSourceAdInfo adInfo)
{
LoadRewardedAd();
}
void RewardedVideoOnAdRewardedEvent(IronSourcePlacement placement, IronSourceAdInfo adInfo)
{
// Show Reward
}
}