Hello,
We recently set up Unity Ads in our game, and in Unity the ad placement, playback, and everything ad related works as intended.
We then build the project to import to Xcode and then publish to app store connect for testing.
We get 0 errors when archiving the app, and all goes well in getting the app to app store connect for testflight.
But upon testing the app, the unity ads popup occurs, you go through the selection and then it plays an ad (We have not coded this in anywhere, and it doesnt do this in Unity). Upon finishing the ad, another ad pops up, and this cycle is repeated:
Here is the code for our ad manager:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;
using UnityEngine.SceneManagement;
public class AdController : MonoBehaviour, IUnityAdsListener
{
public static AdController instance;
private SceneManagement sceneMan;
private string store_id = "apple_id";//apple
private string video_ad = "video";
private string rewarded_video_ad = "rewardedVideo";
private void Awake()
{
if(instance != null)
{
Destroy(gameObject);
}
else
{
instance = this;
DontDestroyOnLoad(gameObject);
}
}
void Start()
{
Advertisement.AddListener(this);
Advertisement.Initialize(store_id, true); // this will be false when we release
if(SceneManager.GetActiveScene().buildIndex == 1)
{
sceneMan = GameObject.Find("SceneManager").GetComponent<SceneManagement>();
}
}
public void showvideoad() //Skippable
{
if (Advertisement.IsReady(video_ad))
{
Advertisement.Show(video_ad);
}
}
public void ShowRewardedVideo()
{
AudioManager.instance.Stop("MenuMusic");
Advertisement.Show(rewarded_video_ad);
}
public void OnUnityAdsDidFinish(string rewarded_video_ad, ShowResult showresult) //Unskippable
{
if (showresult == ShowResult.Finished)
{
if (SceneManager.GetActiveScene().buildIndex == 0)
{
GameManager.Instance.gold += 50;
PlayerPrefs.SetInt("gold", GameManager.Instance.gold);
}
if (SceneManager.GetActiveScene().buildIndex == 1)
{
sceneMan = GameObject.Find("SceneManager").GetComponent<SceneManagement>();
if (!sceneMan.playerController.GetComponent<PlayerController>().gameEnded)
{
print("This shouldnt happen Either");
sceneMan.deathPanelButtons.SetActive(false);
sceneMan.player.SetActive(true);
sceneMan.playerController.GetComponent<PlayerController>().health = 1;
GameManager.Instance.playerAlive = true;
StartCoroutine(sceneMan.PayGoldToCont());
}
if (sceneMan.playerController.GetComponent<PlayerController>().gameEnded)
{
print("This shouldnt happen");
sceneMan.DoubleGoldReward();
}
}
}
else if (showresult == ShowResult.Failed)
{
//Debug.Log("Failed to show advert");
}
}
public void OnUnityAdsDidError(string message)
{
}
public void OnUnityAdsReady(string rewarded_video_ad)
{
Advertisement.Show(rewarded_video_ad);
}
public void OnUnityAdsDidStart(string placementId)
{
print("Helo");
}
}
Any ideas would be greatly appreciated because we are truly lost, and at the point of thinking about removing unity ads altogether and trying a different ads service.
Thanks,
Liam