1. Home
  2. Publishers
  3. Implementing Native Banner Ads in Unity Project (Android)

Implementing Native Banner Ads in Unity Project (Android)

This document contains step by step instructions for integrating Tapsell video ads in your application.

Step 1: Download Tapsell SDK

Download our SDK from the following link and import it in your project:

Step 2: Get App-Key

Log in your Tapsell account and get a new Tapsell key by creating a new application. This key is needed for using Tapsell APIs.

Step 3: Initialize Tapsell

To use tapsell SDK, you must add the namespace.

using TapsellSDK;

The first step is to add a function that will initialize Tapsell SDK. In your C# script, add the below code:

Tapsell.initialize(appKey);

appKey argument is the key you copied from Tapsell website.

Step 4: Requesting a Native Banner Ad

In Native Ads, you can customize visual properties (font, size, color, etc.) of ads so it would match to your app’s design.

In order to achieve this goal, you must send a request and fetch creative of the Native Banner ad and use the creative to show it to the users.

To send an ad request, use the following code:

Tapsell.requestNativeBannerAd(monoBehaviour, zoneId, Action<TapsellNativeBannerAd> onAdAvailableAction,
    Action<string> onNoAdAvailableAction, Action<TapsellError> onErrorAction,
    Action<string> onNoNetworkAction);

In this function, the monoBehaviour parameter is an instance of MonoBehaviour class. zoneId argument indicates the zone in which you with to show the ad. You can get the zoneId from your app page in dashboard.

The result of the request is returned to the actions. A sample implementation of required actions is given below.

Tapsell.requestNativeBannerAd(this, zoneId, 
    (TapsellNativeBannerAd result) => {
       // onRequestFilled
       Debug.Log("Request Filled");
       TapsellNativeBannerAd nativeAd = result; // store this to show the ad later
    },

    (string zoneId) => {
        // onNoAdAvailable
        Debug.Log("No Ad Available");
    },

    (TapsellError error) => {
        // onError
        Debug.Log(error.error);
    },

    (string zoneId) => {
        // onNoNetwork
        Debug.Log("No Network");
    },
);

The returned parameter in onRequestFilled callback which is an instance of  TapsellNativeBannerAd class is the object used to show the native banner ad.

 

Step 5: Showing the Native Banner Ad

To show an ad, you can use methods of TapsellNativeBannerAd class. Description of these methods are given in Table 1.

Table 1 Methods of TapsellNativeBannerAd class
Method Name Description
string getTitle()
Title of the ad
string getDescription()
Description of the ad
string getCallToAction()
Call-to-action text inviting user to click/install
Texture2D getPortraitBannerImage()
Banner of the ad (portrait)
Texture2D getLandscapeBannerImage()
Banner of the ad (landscape)
Texture2D getIcon()
Icon of the ad which is a small square icon of the website/application

Note that ads might not all have both portrait and landscape banners.

You should use the following function when displaying the ad.

nativeAd.onShown ();

 

Step 6: Opening the Native Banner Ad

When the user clicks on the call to action button, you should call the following method to open the landing page.

nativeAd.onClicked ();

 

 

Sample Project

A sample project is located in the following repository in case more information about the SDK is needed.

Please let us know whether this document was helpful and what complications you faced while using Tapsell Android SDK.

 

 

 

Was this article helpful?

Related Articles