I have developed an app. In which, to access level a player needs to purchase or watch rewarded video. To watch a rewarded video player needs to press or tap a button. but when i press a button, nothing is happening!!
I have created a file "AdManager.cs" and the code is as follows:
public class AdManager : MonoBehaviour {
// before codes
.
.
.
//I have created an instance to admanager
public static AdManager Instance {set;get;}
.
.
.
.
void Awake(){
Instance=this;
}
.
.
.
.
//few more codes
.
.
.
public void showRewardBasedVideoAd(){
#if UNITY_ANDROID
string adUnitId = "xxxxxxxxxxxxxxxxxxxxxxx";
#elif UNITY_IPHONE
string adUnitId = "INSERT_IOS_BANNER_AD_UNIT_ID_HERE";
#else
string adUnitId = "unexpected_platform";
#endif
rewardBasedVideoAd = RewardBasedVideoAd.Instance;
rewardBasedVideoAd.OnAdLoaded += HandleOnrewardBasedVideoAdLoaded;
rewardBasedVideoAd.OnAdFailedToLoad += HandleOnrewardBasedVideoAdFailedToLoad;
rewardBasedVideoAd.OnAdOpening += HandleOnrewardBasedVideoAdOpening;
rewardBasedVideoAd.OnAdRewarded += HandleOnrewardBasedVideoAdRewarded;
rewardBasedVideoAd.OnAdClosed += HandleOnrewardBasedVideoAdClosed;
rewardBasedVideoAd.OnAdLeavingApplication += HandleOnrewardBasedVideoAdLeavingApplication;
AdRequest request = new AdRequest.Builder ().Build();
rewardBasedVideoAd.LoadAd (request, adUnitId);
if (rewardBasedVideoAd.IsLoaded ()) {
rewardBasedVideoAd.Show ();
} else {
Debug.Log ("Rewarded Video Ad is not Yet ready!!!!");
}
}
public void HandleOnrewardBasedVideoAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
print("Interstitial Failed to load: " + args.Message);
}
public void HandleOnrewardBasedVideoAdLoaded(object sender, EventArgs args)
{
print("OnAdLoaded event received.");
}
public void HandleOnrewardBasedVideoAdOpening(object sender, EventArgs args)
{
print("OnAdLoaded event received.");
}
public void HandleOnrewardBasedVideoAdClosed(object sender, EventArgs args)
{
print("OnAdLoaded event received.");
}
public void HandleOnrewardBasedVideoAdLeavingApplication(object sender, EventArgs args)
{
print("OnAdLoaded event received.");
}
public void HandleOnrewardBasedVideoAdRewarded(object sender, Reward args)
{
string type = args.Type;
double amount = args.Amount;
print("User rewarded with: " + amount.ToString() + " " + type);
totalPoints += 100;
Debug.Log("100granted");
}
// rest codes
}
I am developing this app in unity and for android platform. I have created unityad mediation in admob rewarded video adunit section. There is mark which is saying pending. I could not able to figure out where is the problem.
Guide me in this regard!!