Applovin, how to integrate?, or sample scene

Hello,

I have difficulties integrating Applovin sdk in unity(for android for now).
they have instructions here:

but the sdk does not contain a sample scene.

I currenlty have a main camera with a script attached:

using UnityEngine;
using System.Collections;

public class applovindemo_by_me : MonoBehaviour {

	// Use this for initialization
	void Start () {
		AppLovin.InitializeSdk ();
		AppLovin.PreloadInterstitial();

	}
	
	// Update is called once per frame
	void Update () {
		//if (Input.GetMouseButtonDown (0)) {
			//AppLovin.PreloadInterstitial();
			//AppLovin.ShowInterstitial();
		AppLovin.ShowAd();
				//}
	}
}

Nothing happens, can someone help me?

Your code is right. Adds show only on mobile device.

i have written the same code but it is not working on mobile too

Use AppLovin.ShowInterstitial(); to show the interstitial. And Use it in a regular public method instead of the Update method. You don’t want to call the AppLovin.ShowInterstitial(); every second.

As soon as you run the game, add this Code:

  void Awake() {
        AppLovin.SetSdkKey("your sdks key here, find it in applovin dashboar");
        AppLovin.InitializeSdk ();
        AppLovin.PreloadInterstitial();

    }

Then whenever you decide to show the ads, call this method:

public void ShowAD()
{
       AppLovin.ShowInterstitial ();
}
2 Likes

Create ApplovinLoader.cs and add following code and assign to any gameObject.

using UnityEngine;
using System.Collections;

public class ApplovinLoader : MonoBehaviour {

public static AppLovin myApplovin = null;
public string SDKKey = "insert SDK key here";

void Start () {

if (SDKKey == "") {

Debug.LogWarning ("Please input AppLovin SDK key to the ApplovinLoader gameobject.");

} else {

myApplovin = AppLovin.getDefaultPlugin ();
myApplovin.setSdkKey (SDKKey);
myApplovin.initializeSdk ();
myApplovin.preloadInterstitial ();
}
}
}

Create ApplovinManager.cs and assign to any GameObject.

using UnityEngine;
using System.Collections;

public class ApplovinManager : MonoBehaviour {

public bool show_Applovin;

void Start () {
show_Applovin = true;
}

void Update () {

if (show_Applovin) {

if (!ApplovinLoader.myApplovin.hasPreloadedInterstitial ()) {

ApplovinLoader.myApplovin.preloadInterstitial ();

} else {

show_Applovin = false;
ApplovinLoader.myApplovin.showInterstitial ();
Debug.Log ("-------------------------Show AppLovin Interstitial.");
}
}
}
}

Enjoy…

2 Likes

thanks