ConsoliAds Mediation Integration

You are here:
Estimated reading time: 11 min

SDK Integration (for v.3.2.2 & above)

Overview

ConsoliAds mediation Unity plugin has a simple inspector view in unity. It requires you to just fill up the information and configure server for instantly synching with server to create all entities automatically. To integrate ConsoliAds mediation Unity plugin, make sure you have:

•  Registered at ConsoliAds

•  Downloaded the latest plugin

•  The compatible Unity version

•  Created app on ConsoliAds portal

Basic Integration Process
For Basic Integration of SDK in your app, please follow below steps:

Download SDK

Download the latest ConsoliAds mediation Unity plugin here and save it in your computer.

Import SDK

•  Open your Unity Project

•  Double click to open your downloaded ConsoliAds plugin

•  Click “All” in the Importing package dialog

  Click “Import” button to import ConsoliAds mediation into your project

NOTE: Ignore any warnings or errors in console if any.

Add Prefab to your Scene

Now in your project explorer go to “Assets\ConsoliAds\Prefab” or search for “ConsoliAds”. Drag and drop prefab into your scene

NOTE: Sample Scene (ConsoliAdsSample) can be used for testing purpose. To load that go to the scene “Splash”.

Fill up Information

In your scene hierarchy tab, select the ConsoliAds prefab. Next, in the Unity Inspector view of ConsoliAds prefab, fill up the required information:

User signature is essential for user identification and can be obtained as follows:

○ Sign in to your ConsoliAds account

○ Go to your Personal Info by clicking on your name in the right corner of the top bar.

○ Copy the required user signature for the inspector view

• Enter your application name in the App Name field

• Select your app platform (Google, Apple, Amazon)

• Enter your application’s unique package name in the Bundle Identifier field.

PLEASE NOTE: package prefixes identify the brand to which user should have rights for the particular app under development

(Optional) You can enter your application’s version in Bundle Version

Specifying Placeholders

In your ConsoliAds inspector you will see a screen just like in the below screenshot.

• As shown in figure, point 1, you will see an expandable option for Scene Array.

• Expand Scene Array and you will see a field “Size” (in figure: point 2).

In the field “Size” enter the number of scenes (places to show ads) you want in your app.

Scene elements will be populated according to your given size. The developer is required to specify ad networks to show in each scene element.

After creating placeholders list (scene array) you need to specify Ad networks to show in each scene. Click on a placeholder’s element such as element 0 (in figure: point 3) and select Placeholder Name: specific application placeholder in which you want your Ads to appear. Now you will see 5 Ad Types:

       • Interstitial and Video: list of interstitial and video ads from mediation Ad Networks to show in this placeholder element.

       • Rewarded Video: list of rewarded Ads from mediation Ad Networks to show in this placeholder element.

       • Native: list of native Ads from mediation Ad Networks to show in this placeholder element.

       • Banner: list of banner Ads from mediation Ad Networks to show in this placeholder element.

       • Icon: list of icon ads from mediation Ad Networks to show in this placeholder element

Enable and fill in the required information for the Ad type you want to show in your app.

Specifying Ad Networks List

Click on the Network List option as highlighted in the below screenshot.

In the field ‘Size’ enter the number of Ad Networks you want to show in this placeholder.

The above image shows Network List Size as 2.

Each element of the list is a drop down to select the required Ad Network.

Fail over is the ad to show if any of the sequence ads fails to show if you select priority in Show Ad Mechanism.

Skip first is a check to skip ad in the first instance.

Configure Server

In ConsoliAds prefab,at the bottom of the inspector there is a button to Configure Server.

Click on the button and your app will be configured with the online server.

The configure server sync works as follows:

It creates the placeholders list, the details from prefab are pushed/overwritten on server.

If the placeholder list size and names are same as created on server, other details of placeholder configuration will be pulled/overwritten in unity from the online server.

Tip: You can also pull placeholders & ads setting from server by making scene array size ‘0’.

Since ad IDs are provided by the managers, ad IDs will be fetched from the server. Auto integrated ad networks do not require ad IDs.

NOTE: Make sure you add ad IDs for non integrated ad networks on ConsoliAds portal, as the ad IDs in inspector are just for display.

Developing for Android

Play Services Resolver

You need to download play services resolver for Android integration from the download Jar Resolver button in unity as shown in the figure or from the following site.

https://github.com/googlesamples/unity-jar-resolver/releases

Download zip file from latest version. Unzip the above downloaded zip file and find the unity package of play resolver. Import it in your current project. It will automatically start downloading play services files. If it is not started automatically then you need to resolve it yourself. Go to Menu->Assets->Play Services Resolver -> Force Resolve.

Now open your project and go to Plugin-> Android folder and make sure that play services ARR/Jar are there.

Note: If play services version is more than 17.x than you need to make sure you follow the steps explained below otherwise your app will crash.

According to Admob documentation if you are using play services version greater than 17.x then you have to make sure that you add your Admob appID inside AndroidManifest.xml file. Otherwise your app will crash. Open your project’s AndroidManifest.xml. You can find this file inside your project’s Assets->Plugin->Android folder. Add the following metadata inside Manifest application tag.

<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-3940256099942544~3347511713"/>

 

Note: This is the test id you need to make sure that you add your Admob appID that you have created in Admob portal.

Developing for IOS

Support for unity 5.x.x

Important:

It is highly recommended that you transfer your project to a MAC and make an Xcode build from there.

Whenever updating standalone plugin, please make sure you delete the previous one for IOS unity.

Go to build settings-> player settings-> Other settings-> Target minimum iOS version set it to 8.0

In your Xcode project, select your target Build Settings and make sure that you have added the following flag in “Other linker Flags”

-ObjC

In your Xcode project, select your target Build Settings and

○  Disable Bitcode option

○  Enable module option (c and objective-c)

○  Enable Objective-C Exceptions

In your Xcode project, select your target Build Phases, inside “Link Binaries With Libraries” drop down add these frameworks

○ Addressbook.framework

○  WatchConnectivity.framework

○  webkit.framework

○  libz.1.2.5.tbd

If you have integrated Facebook in ConsoliAds plugin then in your Xcode project, select your target Build Settings and make sure that you have added the following flag in “Other linker Flags”

-lxml2

If you have made an Xcode build on a Windows PC, you may have to perform the following steps:

Make sure that the following libraries and frameworks are linked to your project. if they are not automatically included, you need to manually add them.

○  libz.1.2.5.tbd

○  libz.tbd

○  libxml2.tbd

○  libobjc.tbd

○  libsqlite3.tbd

○  AddressBook.framework

○  AddressBookUI.framework

○  SystemConfiguration.framework

○  QuartzCore.framework

○  MessageUI.framework

○  MobileCoreServices.framework

○  MediaPlayer.framework

○  EventKitUI.framework

○  EventKit.framework

○  CoreData.framework

○  CoreVideo.framework

○  CoreMotion.framework

○  CoreMedia.framework

○  CoreTelephony.framework

○  CoreText.framework

○  CoreGraphics.framework

○  AVFoundation.framework

○  AVKit.framework

○  AudioToolbox.framework

○  AdSupport.framework

○  Social.framework

○  StoreKit.framework

○  Webkit.framework

Note: If you are using Admob please make sure to add this key in info plist GADApplicationIdentifier and set its value to your admob APPID

Displaying ads in your apps

The Integration process of your app is completed. Now choose which Ad type you want to show in your app and then follow only the required steps according to the selected Ad type.

Plugin Initialization 

Developers need to initialize ConsoliAds manually by writing the following line of code:

ConsoliAds.Instance.initialize(bool userConsent);

userConsent = TRUE if user agrees to share his data and opts for personalized ads, FALSE otherwise

ConsoliAds plugin will initialize IF AND ONLY IF this call is made.

NOTE: There is no possibility of passing the consent to ConsoliAds once it is initialized

If the developer does not want to pass the user consent, then he/she can simply call the initialize method without the parameter. PLEASE NOTE that in this case app will work normally and will be sending the user consent to ad networks as TRUE.

Interstitial/Video Ad

Show static interstitial or video ad as follows:

ConsoliAds.Instance.ShowInterstitial(int sceneIndex);

(sceneIndex: index of the placeholder from the scene list)

Rewarded Video

Loading Rewarded Video:

Showing rewarded video requires loading it beforehand. It is highly recommended to call LoadRewarded(sceneIndex) as early as possible e.g. in the Start() method of a script to allow videos to be pre-loaded.

ConsoliAds.Instance.LoadRewarded(int sceneIndex);

(sceneIndex: index of the placeholder from the scene list)

Showing Rewarded Video:

ConsoliAds.Instance.ShowRewardedVideo(int sceneIndex);

Rewarded Video Completed Callback:

ConsoliAds implements single callBack for rewarded Video Completed event for all ad networks being used for mediation

In the Start() method of your script use the following code to attach your functions with ConsoliAds Rewarded Video Completed callback:

ConsoliAds.onRewardedVideoAdCompletedEvent += onRewardedVideoCompleted;

NOTE: Example given in the Sample script

Banner Ad

From the inspector:

Enable/disable banner

Select banner Size

Select banner Position

To show Banner you need to use the following code:

ConsoliAds.Instance.ShowBanner(int sceneIndex);

To hide Banner, use the following:

ConsoliAds.Instance.HideBanner();

Custom Banner Ad for Admob

How to show Custom Admob banner:

In-order to show banner with custom size, please implement the below code. You can set the size by passing the width and height values.

AdSize size = new AdSize();
size.width = 250;
size.height = 100;
ConsoliAds.Instance.ShowBanner(sceneIndex, size);

In-order to show banner at custom position, please call the below method. You can set the position by passing x and y values.

ConsoliAds.Instance.ShowBanner(sceneIndex, 200.0, 200.0);

In-order to show full custom banner, please implement the below code. You can set the size and position by passing the x,y, width and height values.

AdSize size = new AdSize();
size.width = 320;
size.height = 200;
ConsoliAds.Instance.ShowBanner(sceneIndex, size, 200.0, 200.0);

Native Ad

While integrating Native Ads please keep in mind the following prerequisites:

In prefab of native/icon Pos Z value is “0” only require to set x and y of prefab.

Press ctrl+S to save the settings of prefab and do not click on apply button in unity.

Prefabs of native must be dragged inside canvas.

Main Camera must be tagged with MainCamera.

Native Ad Mediation

Method # 1:

Drag the ‘ConsoliAdsNative’ prefab into your scene (As shown in Figure: point 1).

You can change X value of prefab (as shown in figure: point 3) where you are desired to show native ad by dragging the red arrow horizontally.

You can change Y value of prefab (as shown in figure: point 2) where you are desired to show native ad by dragging the red arrow vertically.

Add sceneIndex to show native Ad (as shown in figure: point 4). (sceneIndex is the index of a scene that you have added in ConsoliAds Portal).

‘ConsoliAdsNative’ prefab has its own script, you just need to add prefab and enter sceneIndex, native shown call be automatically executed when prefab initiate.

ConsoliAds is providing mediation of Native Ads for following ad networks

Facebook

Admob

ConsoliAds

Applovin

StartApp

Leadbolt

Mopub

Mintegral

Inmobi

Mobfox

MyTarget

Method # 2:

To show/hide Native Ad programmatically

First, you need to remove the script attached with the prefab.

Create a game Object variable in your script.

Attach variable with the prefab that you have attached in your scene.

Call to show Native Ad Using ConsoliAds:

ConsoliAds.Instance.ShowNativeAd(GameObject nativeGameObject, int sceneIndex);

Call to hide Native Ad Using ConsoliAds:

ConsoliAds.Instance.HideNative(int sceneIndex);

Icon Ad

While integrating Icon Ads please keep in mind the following prerequisites:

In prefab of native/icon Pos Z value is “0” only require to set x and y of prefab.

Press ctrl+S to save the settings of prefab and do not click on apply button in unity.

Prefabs of icon must be dragged inside canvas.

Main Camera must be tagged with MainCamera.

Icon Ad Mediation

To show IconAd in your scene follow our unity sample project. We have created a prefab to represent single IconAd. When you open ConsoliAdsSample scene, It already has all the required steps to show IconAd.

Method # 1:

Drag the ‘ConsoliAdsIconAd’ prefab into your scene as shown in figure: point 1.

You can change X value of prefab (as shown in figure: point 2) where you are desired to show icon ad by dragging the red arrow horizontally.

You can change Y value of prefab (as shown in figure: point 3)where you are desired to show icon ad by dragging the red arrow vertically.

Add sceneIndex to show Icon Ad as shown in figure: point 4. (sceneIndex is the index of a scene that you have added in ConsoliAds Portal).

• ‘ConsoliAdsIconAd’ prefab has its own script, you just need to add prefab and enter sceneIndex, icon shown call be automatically executed when prefab initiates.

Method # 2:

To show/hide Icon Ad Programmatically

First, you need to remove the script attached with the prefab.

Create a game Object variable in your script.

Attach variable with the prefab that you have attached in your scene.

Call to show Icon Ad using ConsoliAds:

ConsoliAds.Instance.ShowIconAd(GameObject iconAdGameObject , int sceneIndex);

Call to Hide Icon Ad using ConsoliAds:

ConsoliAds.Instance.DestoryIconAd (GameObject iconAdGameObject,int sceneIndex);

Show Multiple Icon Ads

To show multiple Icon Ads, make sure you repeat all steps required to show single Icon Ad. Additional steps that you need to carry out to show multiple Icon Ads are:

Search ‘ConsoliAdsIconAd’ from assets and drag it into Canvas. To duplicate or add multiple IconAd select ‘ConsoliAdsIconAd’ in scene and duplicate  it by using key combination command+D (or control+d on windows) as shown in figure: point 1.

You can change X value of prefab (as shown in figure: point 2) where you are desired to show icon ad by dragging the red arrow horizontally.

You can change Y value of prefab (as shown in figure: point 3) where you are desired to show icon ad by dragging the red arrow vertically.

To show IconAd you need to enter the sceneIndex for each IconAd prefab. (as shown in figure: point 4)

Every prefab has its own script, you just need to add prefab and enter sceneIndex, IconAd shown call be automatically executed when prefab initiates.

If you want to show/hide icon ads yourself, please follow these steps to show multiple icon ads:

Open ConsoliAdsSample script and create variable of type GameObject.

Now follow all the steps as described in above section of IconAd.

Now you need this variable as parameter to call, show & destroy icon Ad.

Call to show IconAd using ConsoliAds:

ConsoliAds.Instance.showIconAd(GameObject iconAdGameObject _2, int sceneIndex);

Call to hide IconAd using ConsoliAds:

ConsoliAds.Instance.DestoryIconAd (GameObject iconAdGameObject_2,int sceneIndex);

Hiding Ads

Important: This will not hide Rewarded ads

If you want to hide all ads, use:

ConsoliAds.Instance.hideAllAds();

You only need to call this function once in your script and the user won’t see any ads.

Using More App URL and Support Email

The more apps URL and support email are added against a particular brand

When an app of that brand is configured, the more apps URL and support email are available to use

To access more apps URL, use:

ConsoliAds.Instance.MoreFunURL()

To access support email, use:

ConsoliAds.Instance.SupportEmail()

Implementing Call Back Events

ConsoliAds implements single callback events for all Ad Networks

You can implement these events to listen to Ad Networks’ impression calls as follows:

ConsoliAds.onInterstitialAdShownEvent += onInterstitialAdShown;
ConsoliAds.onVideoAdShownEvent += onVideoAdShown;
ConsoliAds.onRewardedVideoAdShownEvent += onRewardedVideoAdShown;
ConsoliAds.onPopupAdShownEvent += onPopupAdShown;

Detailed usage is given in the sample script

Check ad availability for Interstitial & Rewarded Video Ad

You can check if Interstitial/Rewarded Video ad is available before showing it

You have to pass the scene index on which you want to check ad availability

This method returns a Boolean depending on availability

For Interstitial:

ConsoliAds.Instance.IsInterstitialAvailable (int sceneIndex);

For Rewarded Video:

ConsoliAds.Instance.IsRewardedVideoAvailable (int sceneIndex);

Coppa Compliance, Child Directed

Enable child directed checkbox in unity inspector, if your app falls under COPPA compliance i.e. for children under 13

Configuring server with this option enabled will update the server accordingly and can be changed later on from the server

ConsoliAds GitHub forum

If you are having any technical issues, you can visit https://github.com/teamconsoliads/sampleapp-unity to view known issues, share problems and suggestions.

Dev Mode

Its a new feature introduced by ConsoliAds to help developers and managers manage their unity apps settings.

How does it work?

Configuring / Syncing any app from inspector won’t affect the live configurations of your app.

Every time you configure server, the new settings would be pushed to ‘Dev Placeholders and Ads’ tab.

If you make your build with dev mode checked, the ad settings from ‘Dev. Placeholder and Ads’ tab would be used.

But, if you make build with dev mode unchecked, the ad settings from ‘Live Placeholder and Ads’ tab would be used.

A new game cannot be synced with scene array size as 0*.

How to implement that?

After you have configured server, open the ‘Placeholder and Ads’ tab of the particular app then click ‘Dev. Placeholder & Ads’ as shown below:

On clicking ‘Dev. Placeholder & Ads’ you will see all the changes you have made from inspector, click ‘Apply on Live App’ to apply these configurations to your live app.

You can also watch this short video to understand the Dev Mode and its implementation.

Was this article helpful?
Dislike 0
Views: 861