Answer the question
In order to leave comments, you need to log in
NullReferenceException: Object reference not set to an instance of an object is thrown when I want to play award video. What to do?
I have a problem, when I run Rewarded ad in my application, I get a NullReferenceException: Object reference not set to an instance of an object.
private RewardBasedVideoAd rewardBasedVideo;
public void Start()
{
MobileAds.Initialize(initStatus => { });
this.rewardBasedVideo = RewardBasedVideoAd.Instance;
this.RequestRewardBasedVideo();
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;
}
private void RequestRewardBasedVideo()
{
string adUnitId = "ca-app-pub-3940256099942544/5224354917";
AdRequest request = new AdRequest.Builder().Build();
this.rewardBasedVideo.LoadAd(request, adUnitId);
}
public void UserOptToWatchAd()
{
if (rewardBasedVideo.IsLoaded())
{
rewardBasedVideo.Show();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question