I followed this tutorial: https://www.youtube.com/watch?v=sU5njx1jn8w&t=691s for Unity Ads Mediation and i couldn’t install admob because it couldn’t build and also adlovin because i don’t have the app live but that’s fine because i just wanted to test unity ads and ironsource but when i compile and i open the file in my phone the function onSdkInitializationCompletedEvent is never called, this is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class AdsManager : MonoBehaviour
{
#if UNITY_ANDROID
string appKey = "1f41c9b05";
#else
string appKey = "unexpected_platform";
#endif
public TextMeshProUGUI totalCoinsTxt;
private void Start()
{
print("Starting Debug");
totalCoinsTxt.text = PlayerPrefs.GetInt("totalCoins").ToString();
print(totalCoinsTxt.text);
IronSource.Agent.validateIntegration();
print("Validated");
IronSource.Agent.init(appKey);
print("Initialized "+appKey);
}
private void OnEnable()
{
print("OnEnable Run");
IronSourceEvents.onSdkInitializationCompletedEvent += SdkInitialized;
print("Sdk command run");
//Add AdInfo Banner Events
IronSourceBannerEvents.onAdLoadedEvent += BannerOnAdLoadedEvent;
IronSourceBannerEvents.onAdLoadFailedEvent += BannerOnAdLoadFailedEvent;
IronSourceBannerEvents.onAdClickedEvent += BannerOnAdClickedEvent;
IronSourceBannerEvents.onAdScreenPresentedEvent += BannerOnAdScreenPresentedEvent;
IronSourceBannerEvents.onAdScreenDismissedEvent += BannerOnAdScreenDismissedEvent;
IronSourceBannerEvents.onAdLeftApplicationEvent += BannerOnAdLeftApplicationEvent;
//Add AdInfo Interstitial Events
IronSourceInterstitialEvents.onAdReadyEvent += InterstitialOnAdReadyEvent;
IronSourceInterstitialEvents.onAdLoadFailedEvent += InterstitialOnAdLoadFailed;
IronSourceInterstitialEvents.onAdOpenedEvent += InterstitialOnAdOpenedEvent;
IronSourceInterstitialEvents.onAdClickedEvent += InterstitialOnAdClickedEvent;
IronSourceInterstitialEvents.onAdShowSucceededEvent += InterstitialOnAdShowSucceededEvent;
IronSourceInterstitialEvents.onAdShowFailedEvent += InterstitialOnAdShowFailedEvent;
IronSourceInterstitialEvents.onAdClosedEvent += InterstitialOnAdClosedEvent;
//Add AdInfo Rewarded Video Events
IronSourceRewardedVideoEvents.onAdOpenedEvent += RewardedVideoOnAdOpenedEvent;
IronSourceRewardedVideoEvents.onAdClosedEvent += RewardedVideoOnAdClosedEvent;
IronSourceRewardedVideoEvents.onAdAvailableEvent += RewardedVideoOnAdAvailable;
IronSourceRewardedVideoEvents.onAdUnavailableEvent += RewardedVideoOnAdUnavailable;
IronSourceRewardedVideoEvents.onAdShowFailedEvent += RewardedVideoOnAdShowFailedEvent;
IronSourceRewardedVideoEvents.onAdRewardedEvent += RewardedVideoOnAdRewardedEvent;
IronSourceRewardedVideoEvents.onAdClickedEvent += RewardedVideoOnAdClickedEvent;
}
void SdkInitialized()
{
print("Sdk in initialized!!");
}
void OnApplicationPause(bool isPaused)
{
IronSource.Agent.onApplicationPause(isPaused);
}
#region banner
public void LoadBanner()
{
IronSource.Agent.loadBanner(IronSourceBannerSize.BANNER, IronSourceBannerPosition.BOTTOM);
}
public void DestroyBanner()
{
IronSource.Agent.destroyBanner();
}
/************* Banner AdInfo Delegates *************/
//Invoked once the banner has loaded
void BannerOnAdLoadedEvent(IronSourceAdInfo adInfo)
{
print("Banner Loaded Event: " + adInfo);
}
//Invoked when the banner loading process has failed.
void BannerOnAdLoadFailedEvent(IronSourceError ironSourceError)
{
print("Banner Failed Event: " + ironSourceError);
}
// Invoked when end user clicks on the banner ad
void BannerOnAdClickedEvent(IronSourceAdInfo adInfo)
{
print("Banner Clicked Event: " + adInfo);
}
//Notifies the presentation of a full screen content following user click
void BannerOnAdScreenPresentedEvent(IronSourceAdInfo adInfo)
{
print("Banner ADScreen presented Event: " + adInfo);
}
//Notifies the presented screen has been dismissed
void BannerOnAdScreenDismissedEvent(IronSourceAdInfo adInfo)
{
print("Banner screen dismissed Event: " + adInfo);
}
//Invoked when the user leaves the app
void BannerOnAdLeftApplicationEvent(IronSourceAdInfo adInfo)
{
print("Banner On AD left application Event: " + adInfo);
}
#endregion
#region interstitial
public void LoadInterstitial()
{
IronSource.Agent.loadInterstitial();
}
public void ShowInterstitial()
{
if (IronSource.Agent.isInterstitialReady())
{
IronSource.Agent.showInterstitial();
}
else
{
Debug.Log("interstitial not ready!!");
}
}
/************* Interstitial AdInfo Delegates *************/
// Invoked when the interstitial ad was loaded succesfully.
void InterstitialOnAdReadyEvent(IronSourceAdInfo adInfo)
{
}
// Invoked when the initialization process has failed.
void InterstitialOnAdLoadFailed(IronSourceError ironSourceError)
{
}
// Invoked when the Interstitial Ad Unit has opened. This is the impression indication.
void InterstitialOnAdOpenedEvent(IronSourceAdInfo adInfo)
{
}
// Invoked when end user clicked on the interstitial ad
void InterstitialOnAdClickedEvent(IronSourceAdInfo adInfo)
{
}
// Invoked when the ad failed to show.
void InterstitialOnAdShowFailedEvent(IronSourceError ironSourceError, IronSourceAdInfo adInfo)
{
}
// Invoked when the interstitial ad closed and the user went back to the application screen.
void InterstitialOnAdClosedEvent(IronSourceAdInfo adInfo)
{
}
// Invoked before the interstitial ad was opened, and before the InterstitialOnAdOpenedEvent is reported.
// This callback is not supported by all networks, and we recommend using it only if
// it's supported by all networks you included in your build.
void InterstitialOnAdShowSucceededEvent(IronSourceAdInfo adInfo)
{
}
#endregion
#region rewarded
public void LoadRewarded()
{
IronSource.Agent.loadRewardedVideo();
}
public void ShowRewarded()
{
if (IronSource.Agent.isRewardedVideoAvailable())
{
IronSource.Agent.showRewardedVideo();
}
else
{
Debug.Log("rewarded not ready!!");
}
}```
/************* RewardedVideo AdInfo Delegates *************/
// Indicates that there’s an available ad.
// The adInfo object includes information about the ad that was loaded successfully
// This replaces the RewardedVideoAvailabilityChangedEvent(true) event
void RewardedVideoOnAdAvailable(IronSourceAdInfo adInfo)
{
}
// Indicates that no ads are available to be displayed
// This replaces the RewardedVideoAvailabilityChangedEvent(false) event
void RewardedVideoOnAdUnavailable()
{
}
// The Rewarded Video ad view has opened. Your activity will loose focus.
void RewardedVideoOnAdOpenedEvent(IronSourceAdInfo adInfo)
{
}
// The Rewarded Video ad view is about to be closed. Your activity will regain its focus.
void RewardedVideoOnAdClosedEvent(IronSourceAdInfo adInfo)
{
}
// The user completed to watch the video, and should be rewarded.
// The placement parameter will include the reward data.
// When using server-to-server callbacks, you may ignore this event and wait for the ironSource server callback.
void RewardedVideoOnAdRewardedEvent(IronSourcePlacement placement, IronSourceAdInfo adInfo)
{
int crrCoin = PlayerPrefs.GetInt("totalCoins");
crrCoin += 100;
PlayerPrefs.SetInt("totalCoins", crrCoin);
totalCoinsTxt.text = PlayerPrefs.GetInt("totalCoins").ToString();
}
// The rewarded video ad was failed to show.
void RewardedVideoOnAdShowFailedEvent(IronSourceError error, IronSourceAdInfo adInfo)
{
}
// Invoked when the video ad was clicked.
// This callback is not supported by all networks, and we recommend using it only if
// it’s supported by all networks you included in your build.
void RewardedVideoOnAdClickedEvent(IronSourcePlacement placement, IronSourceAdInfo adInfo)
{
}
#endregion
}