I made a public static method to show Admob Ads in whichever class I want to and it works fine, but now I'm trying to do the same with Unity Ads but they don't seem to load.
Here's my code:
public class PopUpAds {
public static void ShowUnityIr(Context context) {
// Initialize the SDK:
UnityAds.initialize ((Activity) context, "MY_GAME_ID", true);
IUnityAdsListener myAdsListener = new IUnityAdsListener () {
@Override
public void onUnityAdsReady (String placementId) {
// Implement functionality for an ad being ready to show.
}
@Override
public void onUnityAdsStart (String placementId) {
// Implement functionality for a user starting to watch an ad.
}
@Override
public void onUnityAdsFinish (String placementId, UnityAds.FinishState finishState) {
// Implement functionality for a user finishing an ad.
}
@Override
public void onUnityAdsError (UnityAds.UnityAdsError error, String message) {
// Implement functionality for a Unity Ads service error occurring.
}
};
UnityAds.setListener(myAdsListener);
UnityAds.load("video");
if (UnityAds.isReady("video")) {
UnityAds.show((Activity) context, "video");
}
}
}
To load ads, I simply put
PopUpAds.ShowUnityIr(this);
But ads don't seem to display.
If I put
if (UnityAds.isReady("video")) {
UnityAds.show((Activity) context, "video");
}
method in "onUnityAdsReady" it displays but in a loop (closing ad loads another again and so on).
So can someone tell me what's wrong with my code?
Edit: This is what logs say every time:
I/UnityAds: com.unity3d.services.ads.UnityAdsImplementation.show() (line:215) :: Unity Ads opening new ad unit for placement video