T
T
timonestudio2021-05-04 13:32:18
C++ / C#
timonestudio, 2021-05-04 13:32:18

WHY DON'T ADMOB AD WORK?

In the unit editor, when you start the game, ads are shown.
I put it on the play store and nothing!

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

public class click : MonoBehaviour
{
    // Start is called before the first frame update
    public int persikint;
    public Text text;
    public int clicks;
    private RewardedAd rewardedAd;

    public void Start()
    {
        MobileAds.Initialize(initStatus => { });
        string adUnitId;
#if UNITY_ANDROID
            adUnitId = "Скрыл";
#elif UNITY_IPHONE
            adUnitId = "Не пользуюсь";
#else
        adUnitId = "unexpected_platform";
#endif
        this.rewardedAd = new RewardedAd(adUnitId);

        // Create an empty ad request.
        AdRequest adrequest = new AdRequest.Builder().Build();
        // Load the rewarded ad with the request.
        this.rewardedAd.LoadAd(adrequest);
    }
    void Update()
    {
        if (clicks == 100)
        {
            if (this.rewardedAd.IsLoaded())
            {
                this.rewardedAd.Show();
            }
            clicks = 0;
        }
        print(
                PlayerPrefs.GetInt("persik")
                   );
        text.text = "" + PlayerPrefs.GetInt("persik");
    }
    void OnClick()
    {
        PlayerPrefs.SetInt("persik", PlayerPrefs.GetInt("persik") + 1);
        clicks++;
    }
    public void HandleRewardedAdFailedToShow(object sender, AdErrorEventArgs args)
    {
        MonoBehaviour.print(
            "HandleRewardedAdFailedToShow event received with message: "
                             + args.Message);
    }
    public void HandleRewardedAdFailedToLoad(object sender, AdErrorEventArgs args)
    {
        MonoBehaviour.print(
            "HandleRewardedAdFailedToLoad event received with message: "
                             + args.Message);
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question