Be patient..... we are fetching your source code.
Objectives
Main objective of this blog post is to give you an idea about how to Ads Implementation in Unity Using RevMob
The main objective of this blog is to explain how to implement Ads in Unity. This blog is very useful to developers who don’t know anything about Ad or Ad Implementation in Unity. Here we go through the idea of how to implement Ad in unity by using RevMob SDK.
Unity supports many kind of Ad plugins. Here we are going to focus on how to implement it using RevMob.
Step 1 RevMob
Any advertisers who are willing to report advertised app’s installation can use this SDK. Reporting installation contains number of easy and simple steps and it will start RevMob session. This SDK basically provides banner ads, interstitial ads, links, and popup. Advertisers can implement any of them according to their requirement.
Step 2 Implementation
Following are the steps from which u can get brief idea about how to integrate RevMob SDK in Android as well as in iOS.
2.1 Find Or Create Your App ID
You can find/ create your app IDs from following given link:
You can put banner as well as interstitial ads in their games using RevMob. It also provides links and popups for ads.
2.2 Configuration
To access the RevMob SDK and register your application, you have to get your media ID.
- First of all, download latest available version of the SDK.
- Now, you have to import this SDK as a custom package.
RevMob Unity SDK can be integrate using c# or JavaScript code. Here you have to keep one thing in mind that, you have to test it only in devices, as Ads will not show in Unity editor/ xCode simulator.
2.3 Integrate in iOS
RevMob SDK for iOS supports only in XCode version 4.4.1 or later.
You have to include following two libraries as it is required:
- AdSupport
- StoreKit
You can get more idea by following image:
2.4 Integrate in Android
Here, You have to add following required permission into your AndroidManifest.xml File by using following line of code.
<!-- Required --><uses-permissionandroid:name="android.permission.INTERNET"/
Now, add the required RevMob activity inside the application tag.
<activityandroid:name="com.revmob.ads.fullscreen.FullscreenActivity"android:theme="@android:style/Theme.Translucent"android:configChanges="keyboardHidden|orientation">
Integration:
You can declare IDs using following line of code
private static Dictionary<string, string> REVMOB_APP_IDS = new Dictionary<string, string>() {
{ "Android", "<YOUR_ANDROID_APP_ID>"},
{ "IOS", "<YOUR_IOS_APP_ID>" }
};
You can create object for ads that want to show (Banner / Interstitial) using following line of code.
private static RevMob revmob;
private static RevMobBanner banner;
private static RevMobFullscreen fullscreen;
private static RevMobLink link;
You have to start session using following line of code.
revmob = RevMob.Start (REVMOB_APP_IDS, gameObject.name);
// set gameObject name on which Listener is added
You can Create Ad (Cache Ads in memory) using following line of code.
2.4.1 To Create Banner
banner= revmob.CreateBanner();
2.4.2 To Create Interstitial
fullscreen = revmob.CreateFullscreen ();
You Show Ad (Display on Screen) using following line of code.
2.4.3 To Display Banner
banner.Show();
2.4.4 To Display Interstitial
fullscreen.Show();
2.4.5 To Hide Banner
banner.Hide();
2.4.6 Creating Ad Link
link=revmob.CreateAdLink();
2.4.7 To Open Link
link.Open();
2.5 Listeners
Listeners (which is also called Delegates/Callbacks) help you to follow Ad workflow. Whenever state of the Ad will change RevMob SDK will fore events respectively. It calls specific methods as per the callbacks. For example, if Ad is loaded successfully or not, you can identify whenever user click on Ad etc. Following line of code gives brief idea about it.
You have to implement IRevMobListene, so you can pass GameObject and get appropriate callback message by RevMob SDK.
public class RevMobGameObject : MonoBehaviour, IRevMobListener
{
private RevMob revmob;
public void Awake()
{
revmob = RevMob.Start(appIds, "Your GameObject name");
}
#region IRevMobListener implementation
public void SessionIsStarted ()
{
Debug.Log("Session started.");
}
public void SessionNotStarted (string revMobAdType)
{
Debug.Log("Session not started.");
}
public void AdDidReceive (string revMobAdType)
{
Debug.Log("Ad did receive.");
}
public void AdDidFail (string revMobAdType)
{
Debug.Log("Ad did fail.");
}
public void AdDisplayed (string revMobAdType)
{
Debug.Log("Ad displayed.");
}
public void UserClickedInTheAd (string revMobAdType)
{
Debug.Log("Ad clicked.");
}
public void UserClosedTheAd (string revMobAdType)
{
Debug.Log("Ad closed.");
}
public void InstallDidReceive(string message)
{
Debug.Log("Install received");
}
public void InstallDidFail(string message)
{
Debug.Log("Install not received");
}
public void EulaIsShown()
{
Debug.Log("Eula is displayed");
}
public void EulaAccepted()
{
Debug.Log("Eula was accepted");
}
public void EulaRejected()
{
Debug.Log("Eula was rejected");
}
#endregion
}
2.6 Testing
You have to test you app in basically two ways:
- When Ad received successfully.
- When Ad cannot deliver by any of the reasons.
By Activating Testing mode you can easily get through both of these scenarios. You can get more idea from following image.
Checkout other Ads Implementation in Unity:
I hope you find this blog is very helpful while Ads Implementing in Unity Using RevMob. Let me know in comment if you have any questions regarding Ads Implementation in Unity.
I will reply you ASAP Got an Idea of 3D 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 Unity 3D 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.
iOS8 App Groups