Admob rewarded video ads problem
I put rewarded video ads to my unity game and it works, i can see the video in my phone. The only problem is that i cant control the rewarded video events, I tried to do that when a player finishes to watch the video he will get more coins and also that the video ad button wont be activated:
public void HandleRewardBasedVideoRewarded(object sender, Reward args)
{
videoButton.SetActive(false);
valueScore += PlayerPrefs.GetInt("Currency");
PlayerPrefs.SetInt("Currency", valueScore);
alreadyShowedVideo = true;
gotCoinsText.text = "You got more coins!";
}
btw I also put the handlers in Start function
void Start()
{
this.rewardBasedVideo = RewardBasedVideoAd.Instance;
this.rewardBasedVideo.OnAdLoaded += this.HandleRewardBasedVideoLoaded;
this.rewardBasedVideo.OnAdFailedToLoad += this.HandleRewardBasedVideoFailedToLoad;
this.rewardBasedVideo.OnAdOpening += this.HandleRewardBasedVideoOpened;
this.rewardBasedVideo.OnAdStarted += this.HandleRewardBasedVideoStarted;
this.rewardBasedVideo.OnAdRewarded += this.HandleRewardBasedVideoRewarded;
this.rewardBasedVideo.OnAdClosed += this.HandleRewardBasedVideoClosed;
this.rewardBasedVideo.OnAdLeavingApplication += this.HandleRewardBasedVideoLeftApplication;
}
For some reason when i finish watching the video I dont get more coins and I can still see the video button.
Answer by wuym67123 · Jul 15, 2017 at 02:47 AM
Download those files from Admob Unity3d Plugin Project Home https://github.com/unity-plugins/Unity-Admob or Download all the Unity admob plugin project https://github.com/unity-plugins/Unity-Admob/archive/master.zip
Installation Admob Unity
Open your project in the Unity editor. Navigate to Assets -> Import Package -> Custom Package. Select the AdmobUnityPlugin.unitypackage file. Import all of the files for the plugins by selecting Import. Make sure to check for any conflicts with files
Init Admob Unity Plugin
Create A C# script ,drag the script to a object on scene , add the follow code in the script file
using admob;
Admob.Instance().initAdmob("admob banner id", "admob interstitial id");//admob id with format ca-app-pub-279xxxxxxxx/xxxxxxxx
//Admob.Instance().initAdmob("ca-app-pub-3940256099942544/2934735716", "ca-app-pub-3940256099942544/4411468910");
Here is the minimal code to create an admob video.
Admob.Instance().loadRewardedVideo("ca-app-pub-3940256099942544/1712485313");
video need to be explicitly shown at an appropriate stopping point in your app, check that the video is ready before showing it:
if (Admob.Instance().isRewardedVideoReady()) {
Admob.Instance().showRewardedVideo();
}
Answer by KingKong320 · Aug 28, 2018 at 11:07 AM
this.rewardBasedVideo.OnAdRewarded += this.HandleRewardBasedVideoRewarded; write this line right upper where you are showing ad.
Your answer
![](https://koobas.hobune.stream/wayback/20220612123052im_/https://answers.unity.com/themes/thub/images/avi.jpg)