Hi,
I was showing my game to one of my friends, I had the mobile data turned off as I was profiling the game before I showed him.
When the advertisement button was pressed nothing showed for the ShowResult.Failed, the code is below.
The code does work when the mobile data is turned on, it plays an advert & shows text rewarding the player.
I thought if the add was not shown then the show result ShowResult.Failed would be called. The text in ShowResult.Failed is not getting shown on the screen.
Have I done something wrong or is there another way to update the player?
public void ShowRewardedAd()
{
#if UNITY_ADS
if (!Advertisement.IsReady(rewardedVideo))
{
AdWatchedText.text = "Video failed to load 0 bonus fuel added";
Debug.Log(string.Format("Ads not ready for placement '{0}'", rewardedVideo));
return;
}
ShowOptions options = new ShowOptions { resultCallback = HandleShowResult };
Advertisement.Show(rewardedVideo, options);
#endif
}
#if UNITY_ADS
private void HandleShowResult(ShowResult result)
{
switch (result)
{
case ShowResult.Finished:
Debug.Log("The ad was successfully shown.");
// YOUR CODE TO REWARD THE GAMER
fBRAddsButt.SetActive(false);
//Sets bonus reward fuel when advert watched
FRBInt = RefuelJetPack.fuel * 10;
FRBInt = FRBInt + PlayerPrefs.GetInt("SpaceCountdowns") - RefuelJetPack.fuel;
Debug.Log("FRBINT IN REWARDBONUS = " + FRBInt);
//PlayerPrefs.SetInt ("SpaceBonusRewardInt", BonusRewardInt.loyaltyReward + 1)
if (PlayerPrefs.HasKey("SpaceCountdowns"))
{
PlayerPrefs.SetInt("SpaceCountdowns", FRBInt);
}
AdWatchedText.enabled = true;
GameObject.Find("LimitMarker1").SetActive(false);
GameObject.Find("LimitMarker2").SetActive(false);
//Reset Bonus Awarded and Show Text
FRBInt = RefuelJetPack.fuel * 10;
AdWatchedText.text = "Excellent " + FRBInt + " bonus fuel added";
Invoke("FRBStart", 2.7f);
break;
case ShowResult.Skipped:
Debug.Log("The ad was skipped before reaching the end.");
GameObject.Find("LimitMarker1").SetActive(false);
GameObject.Find("LimitMarker2").SetActive(false);
AdWatchedText.text = "Video was not watched 0 bonus fuel added";
break;
case ShowResult.Failed:
Debug.LogError("The ad failed to be shown.");
AdWatchedText.text = "Video failed to load 0 bonus fuel added";
break;
}
}
#endif