- Home /
Unity ads sometimes do not work on android
I just changed a game over from static admob ads to unity ads. The player clicks on a button, it shows and ad and he gets a coin. This coin is used to play the game.
In windows-unity editor, when this happens it displays a positive result as if the ad played. on my android phone, it played the ads about 10 times and stopped working. So the issue is it is not displaying the ads on android.
I am ready to release the game but can't as the player can't get any coins. I have looked this up on unity's site and there seems to be issue here. I have not found any solutions. Could it be 1)a player can watch only so many ads before being banned? or 2) something with the connection to untiy ads? I would assume this is a big deal to unity as they make money off of this.
I am using unity 5.2.3.
Any help is good. thanks
Answer by RandomCharacters · Nov 22, 2015 at 11:50 PM
Sense yesterday, the ads sometimes appear, sometimes show a black screen and sometimes give a 'playback error' and sometimes nothing. Here is the script I am using. I just copied unity's code and added feedback to see what is going on. This is on android with screen orientation set to landscape.
using UnityEngine;
using UnityEngine.Advertisements;
/////////////////////////////////////////////////////
public class AddCoins : MonoBehaviour
{
static public bool adReady = false;
static public int adState = 0;
/////////////////////////////////////////////////////
public void Update()
{
if (Advertisement.IsReady ("rewardedVideo"))
{
adReady = true;
}
else
{
adReady = false;
}
}
/////////////////////////////////////////////////////
public void ShowRewardedAd()
{
////////////////////////////////////////////////////
if (Advertisement.IsReady ("rewardedVideo"))
{
var options = new ShowOptions { resultCallback = HandleShowResult };
Advertisement.Show ("rewardedVideo", options);
}
}
/////////////////////////////////////////////////////
private void HandleShowResult(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
Debug.Log("The ad was successfully shown.");
adState = 1;
CoinsHas.coinsLeft = CoinsHas.coinsLeft + 1;
break;
case ShowResult.Skipped:
Debug.Log("The ad was skipped before reaching the end.");
adState = 2;
break;
case ShowResult.Failed:
Debug.LogError("The ad failed to be shown.");
adState = 3;
break;
}
}
/////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////
Your answer
Follow this Question
Related Questions
Transform.position not working properly? 2 Answers
Unity Ads can not show more than 1 time after install game 0 Answers
question about unity analytics 0 Answers