So, I implemented admob into my project, the problem is that in Editor it is showing perfectly, both test ad and real one. But after build on Android neither one works.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
using GoogleMobileAds;
public class onClick : MonoBehaviour
{
private RewardedAd rewardedAd;
void Start() {
}
private void OnMouseDown()
{
this.rewardedAd = new RewardedAd("ca-app-pub-5346701446101044/4602400235");
AdRequest request = new AdRequest.Builder().Build();
this.rewardedAd.LoadAd(request);
Debug.Log("Work");
}
}
Sorry, guys, thats not the right code, sorry once again
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
using GoogleMobileAds;
using GoogleMobileAds.Common;
using System;
public class ButtonClick : MonoBehaviour
{
public RewardedAd rewardedAd;
public GameObject obj;
// Start is called before the first frame update
public void Start()
{
MobileAds.Initialize(initStatus => { });
this.rewardedAd = new RewardedAd("ca-app-pub-3940256099942544/5224354917");
AdRequest request = new AdRequest.Builder().Build();
this.rewardedAd.LoadAd(request);
this.rewardedAd.OnUserEarnedReward += HandleUserEarnedReward;
this.rewardedAd.OnAdClosed += HandleRewardedAdClosed;
this.rewardedAd.OnAdFailedToShow += HandleRewardedAdFailedToShow;
}
public void ShowRewardVideo() {
if (rewardedAd.IsLoaded())
{
rewardedAd.Show();
}
}
public void HandleUserEarnedReward(object sender, Reward args)
{
int coins = PlayerPrefs.GetInt("kermamoneta");
int adRew = coins + 15;
PlayerPrefs.SetInt("kermamoneta", adRew);
}
public void HandleRewardedAdClosed(object sender, EventArgs args)
{
Destroy(obj);
}
public void HandleRewardedAdFailedToShow(object sender, AdErrorEventArgs args)
{
Destroy(obj);
}
}