Go to Content



Library

Home > Library

bada developers guide to In-App Advertising

By bada Master | 6539 views | Jan 19, 2012

In‐app advertising presents you with an excellent opportunity to monetize your application. It enables you to sell your application free of cost, and make money at the same time.

In this article, we will describe how to connect to an advertiser through SamsungAdHub and how to implement an Ad function in a bada application.

1.Adding In-App Ad settings

As a first step of adding an Advertisement to your application, you need to setup the ad components at the developer site.
 
For that, you need to

        1. Register your application at the developer site,
        2. Set the required privileges,
        3. Set the required components,
        4. Take care of the payment information,
        5. Sign up with the ad networks and
        6. Configure the ad network settings
 
Let’s go through these steps one by one.

1). Registering an Application

Connect to http://developer.bada.com/ and select My Applications > Application Manager > Generate a New Application Profile to create an app.
You can skip this step, if you are adding this feature to an existing app.


 Creating application profile

2) Setting the privilege

To use the ad feature, select Osp::Ads > Detail and select the AD_SERVICE option in the Select Privileged API Group screen.
                     
         
Setting the privilege in application profile
 

3) Component Setup



To use ad feature in your app, select Component Setup, select the application where the ads will be used and select Advertisement > Inventory Management at the bottom.
Note that, if you cannot see ‘Advertisement’ here, it is because the Privilege - AD_SERVICE described in step 2 has not been selected.
Once you select the ‘Inventory Management’, the Samsung AdHub Page appears.

  

Setting the ad components
 

4) Registering Payment Information



Select Payment Information at the bottom left of the Samsung AdHub page and enter the payment information.
The supported payment methods are ‘Wire Transfer’ and ‘PayPal’.
 
For PayPal, sign up on the https://www.paypal.com webpage and enter the ID in the Payment Information screen.

  

Payment information
 

5) Signing up with advertising networks through the Samsung AdHub


To register a new app, select Inventory > Create New Inventory and enter the app information.When the app information has been completely entered, the advertising information will be displayed.
 

(1) InMobi & Mojiva

If you press the Sign up button next to the banner image, the “pending” message is displayed indicating that the process to request advertisements from inmobi and Mojiva is in progress. SamsungHub links InMobi and Mojiva to your application.



InMobi network registration pending status
 
If the pending step is completed and your app is connected, the message becomes active as shown in the figure below.This process may take some time. If the connection takes too long (3-4 days), please request for assistance using the ‘contact us’ link on the www.samsungHub.com website.



InMobi network connected status

(2) NAVTEQ

Location based advertisements are available through the mobile ad network NAVTEQ.Click on the Sign up button to create your account.



Navteq network registration
 
If you sign in after signing up, a screen appears where you can add your application. To add an application on this screen, click on Generate Adspace and then enter the application information.
When registration is complete, the registered application is displayed as follows and the Status indicator turns green and the AdSpaceId and Publisher Id are generated.

  

Application status in Navteq network
 
Click the NavteQ - Configure button, enter the IDs in the corresponding fields and click Save.
Then you will be able to confirm that the NavteQ status is active.

  

Navteq configuration

 

6) Configuring the Ad network settings


Fill  ad network settings according to your requirements.




Network settings
 
If you have completed this step, the entire Ad settings are completed through the Developer Site. Then an Inventory ID is assigned with a congratulations message.

 

 
AD registration completion screen
 

Now let’s look at how to implement an actual advertisement in the code using the Inventory ID.


2.Implementing the code


Now that you have completed setting up all the components, lets see how we can really add it into your application.

1) Declaring the required class

To create an Ad control, you have to inherit the Osp::Ads::Controls::IAdListener interface that contains the declaration of the OnAdReceived() method. You can keep this declaration in the required header file.
In addition, declare one Osp::Ads::Controls::Ad Class Object as __pAd.

// AdExample.h
 
#include "fads.h"
class Ads : public Osp::Ads::Controls::IAdListener
{
public:
      Ads();
      virtual ~Ads();
 
      result CreateControl(Osp::Ui::Controls::Form* pParentForm);
      void RefreshAd(void);
 
      //IAdListener
      virtual void OnAdReceived(RequestId reqId, const Osp::Ads::Controls::Ad& source, result r,
                                     const Osp::Base::String& errorCode, const Osp::Base::String& errorMsg);
 
 
private:
      Osp::Ads::Controls::Ad* __pAd;
 
};


2) Implementing the methods


Include the header file that you have created above and declare the necessary namespaces.
// Ads.Cpp
 
#include "Ads.h"
 
using namespace Osp::Ads::Controls;
using namespace Osp::Base;
using namespace Osp::Base::Collection;
using namespace Osp::Ui::Controls;

After that, you can create the ad.

As given below, Osp::Ads::Controls::Ad::Construct has an argument that receives the InventoryId. Enter the InventoryID in the ‘Ad registration completion screen’ for this argument.

result Osp::Ads::Controls::Ad::Construct(const Osp::Graphics::Rectangle& rect,
                  const Osp::Base::String& inventoryId, const Osp::Ads::Controls::IAdListener* pListener = null);
 
 Then, set a keyword that describes the advertisement and set additional information for the requested advertisement. The basic procedures are completed.Then add the created ad control to the corresponding form.
Result
Ads::CreateControl(Form* pParentForm)
{
   result r = E_SUCCESS;
 
   __pAd = new Ad();
   r = __pAd->Construct(Osp::Graphics::Rectangle(0, 0, 480, 80), L"2100000352_001", this);
   __pAd->SetTextColor(Osp::Graphics::Color(255, 255, 255));
   __pAd->SetBackgroundColor(Osp::Graphics::Color(0, 0, 0));
 
   // Set keywords
   ArrayList* pKeywordsList = new ArrayList;
   pKeywordsList->Construct();
   pKeywordsList->Add(*(new String(L"bada")));
   pKeywordsList->Add(*(new String(L"Samsung")));
  
   __pAd->SetKeywords(pKeywordsList);
   delete pKeywordsList;
 
   // Set the extra information
   HashMap* pExtraInfoList = new HashMap;
   pExtraInfoList->Construct();
   pExtraInfoList->Add(*(new String(L"gender")), *(new String(L"female")));
   pExtraInfoList->Add(*(new String(L"age")), *(new String(L"10")));
   pExtraInfoList->Add(*(new String(L"interests")), *(new String(L"car,soccer")));
   pExtraInfoList->Add(*(new String(L"location")), *(new String(L"37.5,127.5,10.5")));
   __pAd->SetExtraInfo(pExtraInfoList);
   delete pExtraInfoList;
 
   r = pParentForm->AddControl(*__pAd);
 
   return r;
}

To link to a location-based advertisement, you have to link to an advertisement of the advertisement network NAVTEQ.To link to a location-based advertisement, you have to set the inventoryID and the keyword to NAVTEQ as shown below.

   // Set the inventory id to “”@NAVTEQ”
   __pAds->Construct(Osp::Graphics::Rectangle(0, 0, AD_MIN_WIDTH, AD_MIN_HEIGHT), this, L"@NAVTEQ");

   pKeywordsList = new Osp::Base::Collection::ArrayList;
   pKeywordsList->Construct();
   pKeywordsList->Add(*(new String(L"@NAVTEQ"))); // Set the keyword to “"@NAVTEQ”
   delete pKeywordsList;

The following code is to request refreshing an advertisement.Since the minimum refresh interval is 12 seconds, the refresh interval should be greater than 12 seconds.

void
AdExample::RefreshAd(void)
{
   RequestId reqId;
   __pAd->RequestAd(reqId);
}

If you request this, the OnAdReceived() function is called where you can identify whether the advertisement has been successfully received or not.

void
AdExample::OnAdReceived(RequestId reqId, const Osp::Ads::Controls::Ad& source, result r, const Osp::Base::String& errorCode, const Osp::Base::String& errorMsg)
{
       AppLog("[Received Ad] (reqId=%d, r=%s, errorCode=%S, errorMsg=%S)", reqId,
                                                GetErrorMessage(r), errorCode.GetPointer(), errorMsg.GetPointer());
}

If you completed all of the above, you have finished the basic module to display an Ad on a Form.Now let’s look at how to actually apply an advertisement to a Form using this module in the following section.

3) Adding the ad control to the form

3.1. Declaring the form

To use the Ads module that we created, include the Ads.h file and declare an Ads class object as *__pAds and add the timer function to refresh the advertisement after a certain period of time has passed.
// AdForm.h
#include "Ads.h"
 
class AdForm :
      public Osp::Ui::Controls::Form,
      public Osp::Base::Runtime::ITimerEventListener
{
      …
      virtual void OnTimerExpired(Osp::Base::Runtime::Timer& timer);
      …
 
      Ads                           *__pAds;
      Osp::Base::Runtime::Timer           *__pTimer;
};
 


3.2. Adding the code to get the ad refreshed in a specific time period   

Create and add the Adcontrol in the OnInitializing() function of the Form and call the RefreshAd() function to refresh the advertisement.In addition, run the timer so that the advertisement is changed.
 
#include "AdForm.h"
 
using namespace Osp::Base;
using namespace Osp::Base::Runtime;
using namespace Osp::Ui;
using namespace Osp::Ui::Controls;
 
 
AdForm::AdForm(void):
__pAds(null)
{
}
…
 
result
AdForm::OnInitializing(void)
{
…
      // Add Ads
      __pAds = new Ads();
      __pAds->CreateControl(this);
 
      // Create Timer
      __pTimer = new Timer();
      __pTimer->Construct(*this);
      __pTimer->Start(3000);
 
      return r;
}
 
…
 
void
AdForm::OnTimerExpired(Timer& timer)
{
      __pAds->RefreshAd();
      __pTimer->Start(12000);
}
 
 
 

3. Inserting an Ad in the bada 1.x version.

          An Ad library is provided so that the Ad Control can also be used for versions earlier than bada 2.x. The corresponding library files are in the following folder.

/Tools/badaFOspAdsControls_2.0.3.zip

Now we will explain how to apply the library to a bada 1.x version app.

1.    Add the following privileges to the project.
-   AD_SERVICE
-    SYSTEM_SERVICE
-    TELEPHONY
-    WEB_SERVICE
2.    Copy the library resources in the “AdControl-Package/res” folder and paste them into the “res” folder below the Project folder.
3.    Add the “lib” folder to the Application Project.
4.    Copy the “libAdControls.so” file and paste it into the added “lib” folder.
5.    Right-click over the application Project and select Properties from the popup menu to open the Properties window.
6.    As shown by the figure below, select Properties->C/C++ Build->Settings->bada C++ Linker -> Miscellaneous.
 

 
Adding the library to the project
 
 
7. As shown above, add “${Project_ROOT}/lib/libAdControls.so”.
8. Apply the corresponding Build Configuration to each of the Configuration items changing the selected Configuration items marked with the green square in the figure.
9. Click on Apply marked with the red square in the figure.
10.Click OK to close the window.

Then you can use the Ad Control as in bada 2.x.
You can also use the same code as in bada 2.x.
The figure below shows the execution screen when the AD control is applied.


 
  Ad in version bada 1.x
Did this document help you? Yes | It's good,but ... | Not Helpful