Skip to main content

Optimize App Open Ad Loading Time

Why Optimize?

When using App Open Ads, the loading time is crucial. If the loading time is too long, and the app displays an ad after the user has already started interacting with the game. This results in a lousy user experience and can result in store violations.

How to do it

To have the best user experience, we need to optimize the loading time. The loading time is mainly affected by the following factors:

  1. Only start loading App Open App after SDK is initiliazed.
  2. Only display app-open ads if the user has yet to start playing the game.

Full example

Here is the code example:

using Yodo1.MAS;

public class AdManager : MonoBehaviour
{

private float _startTime = 0f;

private void Awake()
{
Yodo1U3dMas.InitializeMasSdk();

Yodo1U3dMasCallback.OnSdkInitializedEvent += (success, error) =>
{
Debug.Log("[Yodo1 Mas] OnSdkInitializedEvent, success:" + success + ", error: " + error.ToString());
if (success)
{
// Only load app open ads after SDK initialized.
// Delay load other ad formats after openads loaded
LoadAppOpenAds();
}
};
}

private void Update()
{
_startTime += Time.deltaTime;
}

private void LoadAppOpenAds() {
Yodo1U3dAppOpenAd.GetInstance().OnAdLoadedEvent += OnAppOpenAdLoadedEvent;
Yodo1U3dAppOpenAd.GetInstance().OnAdLoadFailedEvent += OnAppOpenAdLoadFailedEvent;
Yodo1U3dAppOpenAd.GetInstance().OnAdOpenedEvent += OnAppOpenAdOpenedEvent;
Yodo1U3dAppOpenAd.GetInstance().OnAdOpenFailedEvent += OnAppOpenAdOpenFailedEvent;
Yodo1U3dAppOpenAd.GetInstance().OnAdClosedEvent += OnAppOpenAdClosedEvent;

Yodo1U3dAppOpenAd.GetInstance().LoadAd();
}

private void OnAppOpenAdLoadedEvent(Yodo1U3dAppOpenAd ad)
{
Debug.Log("[Yodo1 Mas] OnAppOpenAdLoadedEvent event received");
// Only display app open ads if the user hasn't start playing the game.
if (_startTime < 8f) {
Yodo1U3dAppOpenAd.GetInstance().ShowAd();
}
}

private void OnAppOpenAdLoadFailedEvent(Yodo1U3dAppOpenAd ad, Yodo1U3dAdError adError)
{
Debug.Log("[Yodo1 Mas] OnAppOpenAdLoadFailedEvent event received with error: " + adError.ToString());
}

private void OnAppOpenAdOpenedEvent(Yodo1U3dAppOpenAd ad)
{
Debug.Log("[Yodo1 Mas] OnAppOpenAdOpenedEvent event received");
}

private void OnAppOpenAdOpenFailedEvent(Yodo1U3dAppOpenAd ad, Yodo1U3dAdError adError)
{
Debug.Log("[Yodo1 Mas] OnAppOpenAdOpenFailedEvent event received with error: " + adError.ToString());
}

private void OnAppOpenAdClosedEvent(Yodo1U3dAppOpenAd ad)
{
Debug.Log("[Yodo1 Mas] OnAppOpenAdClosedEvent event received");
}
}