Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Applovin, how to integrate?, or sample scene

Discussion in 'Editor & General Support' started by paala, Apr 19, 2014.

  1. paala

    paala

    Joined:
    Mar 24, 2014
    Posts:
    20
    Hello,

    I have difficulties integrating Applovin sdk in unity(for android for now).
    they have instructions here:
    https://www.applovin.com/integration#unity3dIntegration
    but the sdk does not contain a sample scene.

    I currenlty have a main camera with a script attached:

    using UnityEngine;
    using System.Collections;


    Code (csharp):
    1. public class applovindemo_by_me : MonoBehaviour {
    2.  
    3.     // Use this for initialization
    4.     void Start () {
    5.         AppLovin.InitializeSdk ();
    6.         AppLovin.PreloadInterstitial();
    7.  
    8.     }
    9.    
    10.     // Update is called once per frame
    11.     void Update () {
    12.         //if (Input.GetMouseButtonDown (0)) {
    13.             //AppLovin.PreloadInterstitial();
    14.             //AppLovin.ShowInterstitial();
    15.         AppLovin.ShowAd();
    16.                 //}
    17.     }
    18. }
    Nothing happens, can someone help me?
     
  2. Mortalbombat

    Mortalbombat

    Joined:
    Aug 5, 2014
    Posts:
    10
    Your code is right. Adds show only on mobile device.
     
  3. umer-rammay

    umer-rammay

    Joined:
    Jun 5, 2013
    Posts:
    6
    i have written the same code but it is not working on mobile too
     
  4. meshari94

    meshari94

    Joined:
    Nov 22, 2014
    Posts:
    13
    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:

    Code (CSharp):
    1.   void Awake() {
    2.         AppLovin.SetSdkKey("your sdks key here, find it in applovin dashboar");
    3.         AppLovin.InitializeSdk ();
    4.         AppLovin.PreloadInterstitial();
    5.  
    6.     }
    Then whenever you decide to show the ads, call this method:

    Code (CSharp):
    1. public void ShowAD()
    2. {
    3.        AppLovin.ShowInterstitial ();
    4. }
     
    Valnat and ael744055 like this.
  5. bokstudio

    bokstudio

    Joined:
    Jan 29, 2016
    Posts:
    1
    Create ApplovinLoader.cs and add following code and assign to any gameObject.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class ApplovinLoader : MonoBehaviour {
    5.  
    6. public static AppLovin myApplovin = null;
    7. public string SDKKey = "insert SDK key here";
    8.  
    9. void Start () {
    10.  
    11. if (SDKKey == "") {
    12.  
    13. Debug.LogWarning ("Please input AppLovin SDK key to the ApplovinLoader gameobject.");
    14.  
    15. } else {
    16.  
    17. myApplovin = AppLovin.getDefaultPlugin ();
    18. myApplovin.setSdkKey (SDKKey);
    19. myApplovin.initializeSdk ();
    20. myApplovin.preloadInterstitial ();
    21. }
    22. }
    23. }



    Create ApplovinManager.cs and assign to any GameObject.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class ApplovinManager : MonoBehaviour {
    5.  
    6. public bool show_Applovin;
    7.  
    8. void Start () {
    9. show_Applovin = true;
    10. }
    11.  
    12. void Update () {
    13.  
    14. if (show_Applovin) {
    15.  
    16. if (!ApplovinLoader.myApplovin.hasPreloadedInterstitial ()) {
    17.  
    18. ApplovinLoader.myApplovin.preloadInterstitial ();
    19.  
    20. } else {
    21.  
    22. show_Applovin = false;
    23. ApplovinLoader.myApplovin.showInterstitial ();
    24. Debug.Log ("-------------------------Show AppLovin Interstitial.");
    25. }
    26. }
    27. }
    28. }

    Enjoy...
     
    Last edited: Feb 19, 2016
    Valnat and unity_5YT_SzDtpVFRoQ like this.
  6. unity_5YT_SzDtpVFRoQ

    unity_5YT_SzDtpVFRoQ

    Joined:
    Dec 24, 2018
    Posts:
    2