I worked with rewarded ads before and everything worked then one day I open my Unity project and it stopped working, the ad works but the reward doesn’t, I tried multiple methods and checked on the internet for answers but unfortunately nothing worked I will attach the code I would if you can take a look. It doesn’t say that I have errors it just doesn’t work.
If anyone has the answer please let me know
8632494–1160604–AdsManager.cs (2.33 KB)
Please use code-tags when posting code. Also, you should use the dedicated Ads forum.
I’ll move your post.
using UnityEngine;
using UnityEngine.Advertisements;
using UnityEngine.SceneManagement;
public class AdsManager : MonoBehaviour
{
public interface IUnityAdsListener { };
public static int b;
public int a;
public int i;
public int earn;
public int once;
// Start is called before the first frame update
void Start()
{
a = 0;
Advertisement.Initialize("ID");
Advertisement.AddListener((UnityEngine.Advertisements.IUnityAdsListener)this);
}
void Update()
{
a = 0;
i = PlayerPrefs.GetInt("ad");
if (i==4)
{
PlayAd();
PlayerPrefs.SetInt("ad", 0);
}
}
// Update is called once per frame
public void PlayAd()
{
if (Advertisement.IsReady("Interstitial_Android"))
{
Advertisement.Show();
Debug.Log("ad");
}
I attached the code.
}
public void PlayRewardedAd()
{
if (Advertisement.IsReady("Rewarded_Android"))
{
Advertisement.Show("Rewarded_Android");
Debug.Log("played");
once = 1;
}
else
{
Debug.Log("is not ready");
}
}
public void OnUnityAdsReady(string placementId)
{
Debug.Log("ready");
}
public void OnUnityAdsDidError(string message)
{
Debug.Log("error");
Advertisement.RemoveListener((UnityEngine.Advertisements.IUnityAdsListener)this);
}
public void OnUnityAdsDidStart(string placementId)
{
Debug.Log("started");
}
void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
{
if (showResult == ShowResult.Finished)
{
Debug.LogWarning("works");
SceneManager.LoadScene("Main");
}
else if (showResult == ShowResult.Skipped)
{
Debug.LogWarning("The ad did not finish due to an error.");
}
else if (showResult == ShowResult.Failed)
{
Debug.LogWarning("The ad did not finish due to an error.");
}
else
{
Debug.LogError("Error");
}
}
}