Tizen In-app SDK

The Tizen In-app SDK allows you to monetize your Tizen application with a wide range of advertisement formats. From banner ads to full-screen native interstitial ads, you can deliver ads from the InMobi network for a better user experience.

This site introduces Tizen InMobi Ads for Tizen Web applications, native applications, and Unity games.

  • Tizen Web application: Tizen Web applications use the Tizen Web Framework to interact with the Web subsystems. The application is built using Web languages, such as HTML5, CSS, and JavaScript.
  • Tizen Native application: Tizen Native application uses EFL (Enlightenment Foundation Libraries) for the application UI. The application is developed using C and it can access advanced device-specific features.
  • Unity game on Tizen: To use Tizen Ads in your Unity game, you need the Unity SDK version 5.2.2 or above for privilege addition support. The game is developed using C#.

Tizen InMobi Ads allows application sellers to monetize Tizen applications and games with the ads provided by InMobi. The following ad sizes are supported:

  • Small banner: 320 X 50 pixels (InMobi slot #15)
  • Big banner: 300 X 250 pixels (InMobi slot #10)
  • Interstitial: 320 X 480 pixels (InMobi slot #14)

Getting Started with InMobi Ads

Account Creation

Developer will fill the Google Form where the following information will be populated in a Google Sheet:

  • Company Name.
  • Registered email id
  • Registered Contact Number
  • App Names
  • Point of Contact
  • Details related to payment profile (PAN, tax identification number etc.,)
    Developer will agree to terms & conditions in the Google Form.
    InMobi will create accounts for each developer if the account does not already exist.

Registering Application

After account creation, InMobi will register apps and after successful approval of app the generated site id will be shared to the application developer.

Adding the SDK to Your Project

To add the SDK to your project:

  1. Choose the InMobi Ads SDK depending on your application type: native application, Web application, or Unity game:

  2. Check the following sample applications and games and refer to the code snippets in this tutorial.

Tizen InMobi Ads for Web Applications

To use InMobi Ads in Web applications:

  1. For Web applications, include the InMobi JavaScript file to use Tizen InMobi ads:

    <script type="text/javascript" src="http://cf.cdn.inmobi.com/ad/inmobi.js"></script>
    
  2. Request permission by adding the following privileges and access feature to the config.xml file:
    <!--To fetch ads from the InMobi Ads server-->
    <tizen:privilege name="http://tizen.org/privilege/internet"/>
    <!--To launch the browser for showing ads-->
    <tizen:privilege name="http://tizen.org/privilege/application.launch"/>
    <!--To access cross domains-->
    <access origin="*" subdomains="true"></access>
    
  3. Configure the parameters for the Tizen ad <div> element:
    • siteid: Unique ID of your application from registration. (Mandatory)
    • slot: Corresponds to the dimensions of the slot or box where the ads appear in your application. (Mandatory)

      Currently supported slot numbers are 10 (300x250), 14 (320x480), and 15 (320x50).

    • test: This parameter must be true during development and testing phase. It must be made false before publishing the application to receive the live ads.
    • manual: This parameter must be set to true, otherwise it takes the default false value and the ad is rendered before the Web application page is rendered.
    • autoRefresh: This is the auto refresh time in seconds. The minimum accepted value is 20.
    <div id="tizen_15">
       <script type="text/javascript">
    
          var inmobi_conf = 
          {
             siteid: "YOUR SITEID", /* Your site ID from InMobi registration */
             slot: "15",
             test: false,
             manual: true,
             autoRefresh: 20 /* In seconds, the minimum accepted value is 20 */
          };
    
       </script>
       <script type="text/javascript" src="http://cf.cdn.inmobi.com/ad/inmobi.js"></script>
    </div>
    <script type="text/javascript">
       _inmobi.getNewAd(document.getElementById('tizen_15'));
    </script>
    

Tizen InMobi Ads for Native Applications

This section describes the Tizen InMobi Ads APIs for Tizen native (EFL) applications.

The Tizen InMobi Ads SDK (AdlibSDK.zip) includes 1 library (Adlib) and 3 header files. To get started, download the extension SDK. For more information about adding extension SDKs, see Extension SDKs.

To create InMobi ads in native applications:

  1. Request permission by adding the following privileges to the tizen-manifest.xml file:

    <privileges>
       <privilege>http://tizen.org/privilege/network.get</privilege>
       <privilege>http://tizen.org/privilege/internet</privilege>
       <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
    </privileges>
    
  2. Include the important enumerators:

    typedef enum {
        BANNER_AD_POSITION_TOP_LEFT = 0,
        BANNER_AD_POSITION_TOP_CENTER,
        BANNER_AD_POSITION_TOP_RIGHT,
        BANNER_AD_POSITION_CENTER,
        BANNER_AD_POSITION_BOTTOM_LEFT,
        BANNER_AD_POSITION_BOTTOM_CENTER,
        BANNER_AD_POSITION_BOTTOM_RIGHT,
    } banner_adposition_e;
    
    typedef enum {
        BANNER_AD_SIZE_SMALL = 15,
        BANNER_AD_SIZE_BIG = 10,
    } banner_ad_size_e;
    
    typedef enum {
        ADLIB_AD_NO_ERROR,
        ADLIB_AD_INTERNAL_ERROR = 1,
        ADLIB_AD_ADLIB_NOT_INITIALIZED,
        ADLIB_AD_INVALID_AD_HANDLE,
        ADLIB_AD_INVALID_PARAMETERS,
        ADLIB_AD_INVALID_REQUEST,
        ADLIB_AD_NETWORK_ERROR,
        ADLIB_AD_NO_FILL_ERROR,
    } adlib_err;
    
  3. Initialize Adlib.

    To use the functions and data types of Adlib, include the <adlib.h> header file in your application.

    The Adlib has to be initialized by passing a valid site ID obtained in the InMobi registration.

    #include <adlib.h>
    
    adlib_err ret;
    ret = adlib_init("YOUR SITEID"); /* Your site ID from InMobi */
    

    To deinitialize Adlib, call the adlib_deinit() function. This is required when exiting the application to free the connection resources.

    ret = adlib_deinit();
    
  4. Create ads:
    • Create a banner ad:

      1. To create a banner ad to be shown in the app, include <adlib_banner_adview.h> header file in your application:

        #include <adlib_banner_adview.h>
        

        Add the banner ad by specifying in (ad->layout) the type of ad along with the layout in which the banner ad must be displayed:

        Evas_Object *ad_obj = NULL;
        
        adlib_err result = adview_ad_banner_ad(&ad_obj, ad->layout, BANNER_AD_SIZE_BIG);
        
      2. Load the created banner ad by calling the adview_banner_load() function:

        result = adview_banner_load(ad_obj);
        
      3. Manage the ad:
        • By default, the auto refresh option is enabled for banner ads and the ads are refreshed every 30 seconds provided a new ad is downloaded from the server. The application can control the refresh timer as well as disable the auto refresh option as shown in the following example.

          result = adview_banner_set_enable_auto_refresh(ad_obj, EINA_FALSE);
          result = adview_banner_set_refresh_interval(ad_obj, 40);
          
        • If the application has not swallowed the banner_ad_obj object into the edc part, it can position the ad at predefined positions using the banner_adposition_e enumeration:

          result = adview_banner_ad_set_position(ad_obj, BANNER_AD_POSITION_TOP_CENTER);
          

          Adlib handles the repositioning of the ad object when the device orientation changes. If the application changes the position of the banner_ad_obj object using Evas functions, such as evas_object_move(), the application is responsible for handling device orientation changes.

          By default, the ad object is placed at BANNER_AD_POSITION_BOTTOM_CENTER.

        • Adlib has a callback mechanism to update the application about the ad state. The following example shows the callbacks the application has to register.
          void
          set_listeners(void *appdata)
          {
              banner_ad_event_callback_s callback = {0,};
              callback.banner_ad_opened = on_ad_opened;
              callback.banner_ad_load_request_failed = on_request_failed;
              callback.banner_ad_load_request_succeeded = on_request_succeeded;
              adview_banner_ad_register_callbacks(banner_ad_obj, &callback, appdata);
          }
          
    • Create an interstitial ad:
      1. To create an interstitial ad to be shown in the application, include the <adlib_interstitial_adview.h> header file in your application:

        #include <adlib_interstitial_adview.h>
        
      2. Add the interstitial ad by specifying the layout or window on which interstitial ad has to be displayed:
        adlib_err result = adview_add_interstitial_ad(ad->layout);
        
      3. The application needs to load the interstitial ad, and on successful load, it needs to call show. Once the load is successful, the interstitial_ad_load_request_succeeded callback is triggered. After this, the interstitial ad is ready to be shown.
        result = adview_interstitial_load();
        

        After receiving the interstitial_ad_load_request_succeeded callback, the application can show the ad at any time as per application logic.

        result = adview_interstitial_show(); /* Show the interstitial ad */
        

        Contrary to the banner ad, the call to load does not take care of showing the interstitial ad.

      4. Adlib has a callback mechanism to update the application about the interstitial ad state. The following example shows the callbacks the application has to register.
        void
        set_listeners(void *appdata)
        {
            interstitial_ad_event_callback_s callback = {0,};
            callback.interstitial_ad_opened = on_ad_opened;
            callback.interstitial_ad_closed = on_ad_closed;
            callback.interstitial_ad_load_request_failed = on_request_failed;
            callback.interstitial_ad_load_request_succeeded = on_request_succeeded;
            adlib_interstitial_ad_register_callbacks(&callback, appdata);
        }
        

Tizen InMobi Ads for Unity Games

This section describes the Tizen InMobi Ads APIs for Tizen Unity games.

To get started, download the Unity package. For more information about setting up the Unity SDK for Tizen, see the Unity documentation. The minimum Unity SDK version for integrating with Tizen is 5.2.2.

To create InMobi ads for Unity games:

  1. The game needs the following capabilities for the Unity game in the Tizen build settings:

  2. Include the important enumerations:
    public enum ErrorType
    {
        ADLIB_AD_NO_ERROR = 0,
        ADLIB_AD_INTERNAL_ERROR = 1,
        ADLIB_AD_ADLIB_NOT_INITIALIZED, 
        ADLIB_AD_INVALID_AD_HANDLE,
        ADLIB_AD_INVALID_PARAMETERS,
        ADLIB_AD_INVALID_REQUEST,
        ADLIB_AD_NETWORK_ERROR,
        ADLIB_AD_NO_FILL_ERROR
    }
    
    public enum BannerAdSize
    {
        BANNER_AD_SIZE_BIG=10,
        BANNER_AD_SIZE_SMALL=15
    }
    
    public enum BannerAdPosition
    {
        BANNER_AD_POS_TOP_LEFT=0,
        BANNER_AD_POS_TOP_CENTER,
        BANNER_AD_POS_TOP_RIGHT,
        BANNER_AD_POS_CENTER,
        BANNER_AD_POS_BOTTOM_LEFT,
        BANNER_AD_POS_BOTTOM_CENTER,
        BANNER_AD_POS_BOTTOM_RIGHT         
    }
    
  3. Initialize Adlib.

    To use the functions of Adlib, get the AdProvider instance by writing the following code in the script file:

    Using Tizen.AdLib;
    AdProvider adobject = AdProvider.Instance;
    

    Initialize Adlib by passing a valid site ID obtained from the InMobi registration.

    ErrorType result = adobject.InitAdlib("YOUR SITEID"); // Your site ID from InMobi
    

    To deinitialize Adlib, call the following function. This is required when exiting the game to free the connection resources and to destroy the created adviews.

    result = adobject.DeinitAdlib();
    
  4. Create banner ads and interstitial ads:
    • Create a banner ad:

      1. Add the banner ad by calling the following function:

        IntPtr adhandle;
        result = adobject.AddBannerAd(BANNER_AD_SIZE_SMALL, out adhandle);
        
      2. Load the created banner ad using the BannerAdLoad() function:
        result = adobject.BannerAdLoad(adhandle);
        
      3. Manage the ad:
        • By default, the auto refresh option is enabled for banner ads and the ads are refreshed every 30 seconds provided a new ad is downloaded from the server. The game can control the refresh timer as well as disable the auto refresh option as shown in the following example.

          result = adobject.BannerAdEnableAutoRefresh(adhandle, false);
          result = adobject.BannerAdSetRefreshInterval(adhandle, 40);
          
        • The game can positon ads at predefined positions using the BannerAdSetPosition() function. Adlib takes care of device orientation changes.

          result = adobject.BannerAdSetPosition(adhandle, BANNER_AD_POS_TOP_CENTER);
          

          The game can positon the ad to any (x, y) position using the BannerAdSetMove() function. The game is responsible for handling the device orientation changes in this situation.

          result = adobject.BannerAdSetMove(adhandle, 100, 200);
          

          By default, the ad object is placed at BANNER_AD_POS_BOTTOM_CENTER.

        • The visibility of the ad view has to be managed by the game while switching between views using the following function:

          result = adobject.BannerAdSetVisibility(adhandle, false);
          
      4. Adlib has a callback mechanism to update the game about the ad state. The game has to register the callbacks with Adlib using the following functions:
        // Implement the BannerAdListener interface
        
        public class AdListener:BannerAdListener
        {
            public void OnAdLoadSucceeded(IntPtr handle, ErrorType error)
            {
                Debug.Log("Entered in to OnAdLoadSucceeded handle is" + handle);
            }
            public void OnAdLoadFailed(IntPtr handle, ErrorType error)
            {
                Debug.Log("Entered in to OnAdLoadFailed");
            }
            public void OnAdClicked(IntPtr handle, ErrorType error)
            {
                Debug.Log("Entered in to OnAdClicked handle is" + handle);
            }
        }
        
        // Pass the listener object to the AdProvider
        
        public AdListener adListener;
        ErrorType ret = adobject.SetBannerAdListener(adhandle, adlistener);
        
    • Create an interstitial ad:
      1. Add an interstitial ad by calling the following function:

        ErrorType result = adobject.AddInterstitialAd();
        
      2. The game needs to load the interstitial ad and on successful load, it needs to call show. Once the load is successful, the OnAdLoadSucceeded callback is triggered by the Adlib. After this the interstitial ad is ready to be shown.
        result = adobject.InterstitialAdLoad();
        

        After receiving the OnAdLoadSucceeded callback, the game can show the ad at any time.

        result = adobject.InterstitialAdShow(); // Show the interstitial ad
        

        Contrary to the banner ad, the call to load does not take care of showing the interstitial ad.

      3. Adlib has a callback mechanism to update the game about the interstitial ad state. The game has to register listener callbacks with Adlib using the following functions:
        // Implement the InterstitialAdListener interface
        
        public class AdListener:InterstitialAdListener
        {
            public void OnAdLoadSucceeded(IntPtr handle)
            {
                Debug.Log("Entered in to OnAdLoadSucceeded handle is" + handle);
            }
                public void OnAdLoadFailed(IntPtr handle, ErrorType error)
            {
                Debug.Log("Entered in to OnAdLoadFailed");
            }
            public void OnAdOpened(IntPtr handle)
            {
                Debug.Log("Entered in to OnAdOpened handle is" + handle);
            }
            public void OnAdClosed(IntPtr handle)
            {
                Debug.Log("Entered in to OnAdClicked handle is"+ handle);
            }
        }
        
        // Create the listener object and set it to AdObject
        AdListener myListener;
        result = adobject.SetInterstitialAdListener(myListener);