Unity Google Mobule Ads do not work in code

27 Views Asked by At

I have a big problem with this, and I haven’t been able to find an answer on the Internet for a long time. So my last hope is you, if you can help me, I will be in 7th heaven. I have the same problem, with this code I get 4 errors. Here they are: 'RewardedAd' does not contain a constructor that takes 1 arguments; 'RewardedAd' does not contain a definition for 'OnAdLoaded' and no accessible extension method 'OnAdLoaded' accepting a first argument of type 'RewardedAd' could be found (are you missing a using directive or an assembly reference?); The name 'HandleAdLoaded' does not exist in the current context; RewardedAd' does not contain a definition for 'LoadAd' and no accessible extension method 'LoadAd' accepting a first argument of type 'RewardedAd' could be found (are you missing a using directive or an assembly reference?); There is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
using System;

public class AdShower : MonoBehaviour
{
    private string rewardedUnitId = "MyId";
    private RewardedAd rewardedAd;

    private void OnEnable()
    {
        rewardedAd = new RewardedAd(rewardedUnitId);  
        AdRequest request = new AdRequest.Builder().Build();
        rewardedAd.LoadAd(request);
        rewardedAd.OnAdLoaded += HandleAdLoaded;
    }
}

I have already spent 50 minutes searching for a solution to the problem on the Internet, but nothing came of it, the most I found was when the class name had a conflicting name

0

There are 0 best solutions below