I have been stuck on this for a long time but I figured out how to add ads to my game via Unity Ads instead of using an older form of ad implementation. Unity Ads and the ads implementation runs just fine, but once a player watches the ad, they aren’t rewarded. They click on a button to watch an ad, the ad plays, then they are supposed to be brought to a screen with another button which awards the player with a random number of premium items.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
public class UnityMonetizationTutorial : MonoBehaviour, IUnityAdsListener
{
string GooglePlay_ID = "1234567";
string AppleApp_ID = "7654321";
string myPlacementId = "rewardedVideo";
bool TestMode = false;
// Start is called before the first frame update
void Start()
{
Advertisement.AddListener(this);
Advertisement.Initialize(GooglePlay_ID, TestMode);
}
// This script is attached to the WatchButton as a component.
public void DisplayInterstitialAd()
{
Advertisement.Show();
}
public void DisplayVideoAd()
{
Advertisement.Show(myPlacementId);
}
// Implement IUnityAdsListener interface methods:
public void OnUnityAdsDidFinish (string placementId, ShowResult showResult)
{
// Define conditional logic for each ad completion status:
if (showResult == ShowResult.Finished)
{
// Reward the user for watching the ad to completion.
Debug.LogWarning ("You Get A Reward");
}
else if (showResult == ShowResult.Skipped)
{
// Do not reward the user for skipping the ad.
Debug.LogWarning ("You DON'T Get A Reward");
}
else if (showResult == ShowResult.Failed)
{
Debug.LogWarning ("The ad did not finish due to an error.");
}
}
public void OnUnityAdsReady (string placementId)
{
// If the ready Placement is rewarded, show the ad:
if (placementId == myPlacementId)
{
}
}
public void OnUnityAdsDidError (string message)
{
// Log the error.
}
public void OnUnityAdsDidStart (string placementId)
{
// Optional actions to take when the end-users triggers an ad.
}
}