I
I
ilemontree2018-06-06 12:53:02
Unity
ilemontree, 2018-06-06 12:53:02

What to do if Admob ads are not shown in the game on Unity3D?

I would like to use ads in an android application (not posted on google play). I made a script with examples:

The code
// Все 'adUnitId' и 'appId' указаны верно.
    using UnityEngine;
    using System;
    using System.Collections;
    using GoogleMobileAds.Api;
    
    public class GoogleAdsController : MonoBehaviour {
    
    	private RewardBasedVideoAd rewardBasedVideo;
    
    	public void Show(){
    		if(rewardBasedVideo.IsLoaded()) {
    			rewardBasedVideo.Show();
    		}
    	}
    
    	public void Start(){
    		string appId = "---";
    
    		MobileAds.Initialize(appId);
    
    		this.rewardBasedVideo = RewardBasedVideoAd.Instance;
    
    		rewardBasedVideo.OnAdLoaded += HandleRewardBasedVideoLoaded;
    		rewardBasedVideo.OnAdFailedToLoad += HandleRewardBasedVideoFailedToLoad;
    		rewardBasedVideo.OnAdOpening += HandleRewardBasedVideoOpened;
    		rewardBasedVideo.OnAdStarted += HandleRewardBasedVideoStarted;
    		rewardBasedVideo.OnAdRewarded += HandleRewardBasedVideoRewarded;
    		rewardBasedVideo.OnAdClosed += HandleRewardBasedVideoClosed;
    		rewardBasedVideo.OnAdLeavingApplication += HandleRewardBasedVideoLeftApplication;
    
    		this.RequestRewardBasedVideo();
    	}
    	
    	private void RequestRewardBasedVideo(){
    		string adUnitId = "---";
    
    		AdRequest request = new AdRequest.Builder().Build();
    
    		this.rewardBasedVideo.LoadAd(request, adUnitId);
    	}
    
    	public void HandleRewardBasedVideoLoaded(object sender, EventArgs args){
    		Debug.Log("HandleRewardBasedVideoLoaded event received");
    	}
    	
    	public void HandleRewardBasedVideoFailedToLoad(object sender, AdFailedToLoadEventArgs args){
    		Debug.Log("HandleRewardBasedVideoFailedToLoad event received with message: " + args.Message);
    	}
    	
    	public void HandleRewardBasedVideoOpened(object sender, EventArgs args){
    		Debug.Log("HandleRewardBasedVideoOpened event received");
    	}
    	
    	public void HandleRewardBasedVideoStarted(object sender, EventArgs args){
    		Debug.Log("HandleRewardBasedVideoStarted event received");
    	}
    	
    	public void HandleRewardBasedVideoClosed(object sender, EventArgs args){
    		Debug.Log("HandleRewardBasedVideoClosed event received");
    	}
    	
    	public void HandleRewardBasedVideoRewarded(object sender, Reward args){
    		string type = args.Type;
    		double amount = args.Amount;
    		Debug.Log("HandleRewardBasedVideoRewarded event received for " + amount.ToString() + " " + type);
    	}
    	
    	public void HandleRewardBasedVideoLeftApplication(object sender, EventArgs args){
    		Debug.Log("HandleRewardBasedVideoLeftApplication event received");
    	}
    }

But when I call the method Show(), it writes in the log Dummy ShowRewardBasedVideoAdand nothing happens, there is no advertising. What to do?
I saw some testId, but did not understand where to get it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Gaydak, 2018-06-06
@ilemontree

you would throw off the entire log from the application. from a real device.
there is almost certainly a line about the fact that the campaign for your application is empty and there are no ads yet.
if you only set it up, then advertising will not appear immediately. For this, there is a description about test advertising and test device IDs.
https://developers.google.com/admob/unity/test-ads
when running on a device in the console you will see in the log
To get test ads on this device, call:
request.testDevices = @[ "2077ef9a63d2b398840261c8221a0c9b" ];
as actually described .. and then add a test device .. rebuild. and view a test ad.
IDs of test ads are also listed there
if the test will show. then real ads will also be displayed. with time. after the first N requests and something else)) in general, when Google activates the company for this application ..
well, a note. for clicks and impressions of non-test advertising in large quantities for development purposes - I can scold, or even block (considering cheating). That's why test advertising was invented.
good luck

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question