Be patient..... we are fetching your source code.
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
- Goto Leadbolt App Portal
- Create new app if not created.
- A popup window appears. Add App Name, Select Platform, and Select App Category.
- Click on Next button. It will display Integration Details.
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. - 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.
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.
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
<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;
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.
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.
Basecamp API using Laravel in Web