THIS CONTENT DOWNLOAD SHORTLY

Objective

The main objective of this blog post is to help you understand the implementation of Ads in Unity using Leadbolt.

 

 

Step 1 Introduction

Leadbolt basically provides interstitial ad as well as rewarded video.

Following are steps through which you can get a brief idea on how to implement Leadbolt in you game.

 

Step 2 Find/Create Your App ID

  1. Goto Leadbolt App Portal
  2. Create new app if not created.

    create-new-app
  3. A popup window appears. Add App Name, Select Platform, and Select App Category.

    setup-leadbolt
  4. Click on Next button. It will display Integration Details.

    integrating-leadbolt
    It will display an API key for the app. Copy the key and store it. You will need at the time of integration in Unity.
  5. Your app will display in the App Portal. It will create a Network Ads section by default. You can create more by click on Add Section button.

    add-section
 

Step 3 Configuration in Unity

To use the Leadbolt plugin, download latest Leadbolt plugin by following link:
https://help.leadbolt.com/app-developers/

Import the downloaded plugin in Unity as a custom package.
To import plugin, goto Asset -> Import Package -> Custom Package.

custom-package
Create an empty GameObject and add Ad.cs and AppTracker.cs script to that object.
Now you have to do some basic integration steps to use Leadbolt.

 

3.1 Integrate in Android

Add required permission to your AndroidManifest.xml file outside of tag.

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Add required activity to AndroidManifest.xml file before tag.

<activity android:configChanges="keyboard|keyboardHidden| orientation|screenSize" android:name="com.apptracker.android.module.AppModuleActivity" android:label="ModuleActivity" android:hardwareAccelerated="false">
</activity>

Now I will move create(cache) and display ad by programming.

 

Step 4 Cache and Display Ads

  • You have to start session before create and load the Ads.
    AppTrackerAndroid.startSession("YOUR_API_KEY");
  • Cache the interstitial Ad
    AppTrackerAndroid.loadModuleToCache ("inapp");
  • Load the interstitial Ad
    if (AppTrackerAndroid.isAdReady ("inapp"))
    {
        AppTrackerAndroid.loadModule ("inapp");
    }
  • Cache rewarded video
    AppTrackerAndroid.loadModuleToCache ("video");
  • Load the rewarded video
    if (AppTrackerAndroid.isAdReady ("video"))
    {
        AppTrackerAndroid.loadModule ("video");
    }
 

Step 5 Register and get Leadbolt callbacks methods

  • Register Leadbolt delegate methods. Add following lines of code to OnEnable() method.
    AppTrackerAndroid.onModuleClosedEvent += onModuleClosedEvent;
    AppTrackerAndroid.onModuleFailedEvent += onModuleFailedEvent;
    AppTrackerAndroid.onModuleLoadedEvent += onModuleLoadedEvent;
    AppTrackerAndroid.onModuleCachedEvent += onModuleCachedEvent;
  • Remove Leadbolt delegate methods. Add following lines of code to OnDisable() method.
    AppTrackerAndroid.onModuleClosedEvent -= onModuleClosedEvent;
    AppTrackerAndroid.onModuleFailedEvent -= onModuleFailedEvent;
    AppTrackerAndroid.onModuleLoadedEvent -= onModuleLoadedEvent;
    AppTrackerAndroid.onModuleCachedEvent -= onModuleCachedEvent;
    When Leadbolt delegates are registered, it calls its delegate methods. Following are the delegates methods.
    void onModuleClosedEvent (string placement)
    {
        print ("onModuleClosed:" + placement);  
    }
    
    void onModuleFailedEvent (string placement, string error, bool cached)
    {
        print ("onModuleFailed:" + placement + ":" + error + ":" + cached);
    }
    
    void onModuleLoadedEvent (string placement)
    {
        print ("onModuleLoaded:" + placement);
    }
    
    void onModuleCachedEvent (string placement)
    {
        print ("onModuleCached:" + placement);
    }
    
    void onModuleClickedEvent (string placement)
    {
        print ("onModuleClicked:" + placement);
    }
    
    void onMediaFinishedEvent (bool viewCompleted)
    {
        print ("onMediaFinished:" + viewCompleted);
    }
 

Step 6 Test Mode

How to display live ad?

  • Submit your app for approval.
  • After approval of your app, it will display live Ads.

    submit-for-approval-go-live

I hope you find this project very helpful while Ads Implementation in Unity Using Leadbolt. Let me know in comment if you have any questions regarding Unity. I will reply you ASAP.

Got an Idea of Game Development? What are you still waiting for? Contact us now and see the Idea live soon. Our company has been named as one of the best Game Development Company in India.

I am 2D Game developer and iOS Developer with an aspiration of learning new technology and creating a bright future in Information Technology.

face mask Belial The Demon Headgear Pocket Staff Magic