090814_0531_Integrating1.png

Integrating Vserv ads in Windows Phone 8 app

Vserv’s new WP8 SDK offers offers a great opportunity to monetize your apps or games with only a small amount of additional effort. The Vserv.mobi WP8 SDK is designed to help you integrate Vserv Ads in your application and fast track your way to monetizing your WP8 applications.

Step 1. Register an account on vserv.mobi

If you already have a developer account at verv then skip to next step otherwise visit the following link to create a new account.

http://www.vserv.mobi/get-started/?at=developer

 

 

Step 2. Get your Zone ID from verv dashboard

Note down your ZoneID. This will be required later on when you use the WP8 SDK to request Ads. The default ZoneID will be available in your welcome email or you could visit https://admin.vserv.mobi/admin/affiliate-zones.php to get a list of all your zones.

 

 

Step 3. Get the vserv SDK for Windows Phone 8

Method I

The first step to integrating Vserv SDK in your WP8 application is to download our SDK package. The SDK package is available at the following link

http://www.vserv.mobi/sdk/WindowsPhone/VservWP8SDK.zip

We suggest that you unzip the SDK Zip file that you just downloaded into a temporary folder. You would find two folders in it, WP8V2SDK and SampleApp.

  • Add a reference to vservWindowsPhone.dll to your project (Refer to this article if you get struck in adding a reference)
  • Add the Images folder to your project from the vserv SDK folder

Method II

Alternatively the SDK can also be downloaded as NuGet package using the following command in the Nuget package manager (Refer to this article if you get struck in adding a reference).

Install-Package mobi.vserv.ads

Step 4. Add the following capabilities in your project

You also need to make sure that your project has the following capabilities

  • ID_CAP_NETWORKING”
  • ID_CAP_MEDIALIB_AUDIO”
  • ID_CAP_MEDIALIB_PLAYBACK”
  • ID_CAP_WEBBROWSERCOMPONENT”
  • ID_CAP_IDENTITY_DEVICE”
  • ID_CAP_IDENTITY_USER”
  • ID_CAP_PHONEDIALER
  • ID_CAP_REMOVABLE_STORAGE

 

 

Step 5. Requesting vserv ads

Using vserv SDK you can either have banner ads or full page interstitial ads in your application. Before you request for Ads you need to make sure you initialize the VservAdControl. Ideally you should initialize this when defining it in your project before the calling constructor.

VservAdControl VMB = VservAdControl.Instance;

Interstitial ads

To request an interstitial you need to call the displayAd() method.

VMB.DisplayAd(zoneID, LayoutRoot);

Note:

  • displayAd() is a part of the VservAdControl (vservWindowsPhone library) which need to be initialized before requesting for an Ad.
  • Optionally you can also set a timeout using the SetRequestTimeOut (timeout) method.
  • Make sure you pass LayoutRoot, else the full-screen ad will be displayed in the small banner.

Banner ads

You can request for Banner Ads which auto refresh automatically in a specific View using RenderAd() method.

Firstly, add an AdGrid in your MainPage.xaml file

<Grid Name=”AdGrid1″></Grid>

Then in the LayoutRoot loaded event handler add the code to render banner ads in your AdGrid1

Note: The RenderAd function takes two parameters

  • First is the zoneID which you copied from your dashboard earlier
  • Second is the name of the grid in which you wish to display ads

Callback functions

 

No Fill Callback

Sometimes vserv fails to deliver an ad. You would need to remove or hide the Banner Control when working with Banner Ads and other ad networks in its place.

void VACCallback_OnVservAdNoFill(object sender, EventArgs e)

Network Error Callback

At times when you request for an ad, there might not be any network available during the request, in which case the Vserv SDK calls the following method.

void VACCallback_OnVservAdNetworkError(object sender, EventArgs e)

Ad Close Callback

This is an essential callback which you need to implement. The Vserv Ads make use of the ApplicationBar to provide a native experience to the user, this is achieved by taking over your ApplicationBar. Thus, ideally you need to reinitialize your ApplicationBar in this callback. This is called when the user returns to your App from the Ad

void VACCallback_OnVservAdClosing(object sender, EventArgs e)

Get the full project source code here,

Download full project source code Vserv-ads.zip

Vivek Maskara

I am pursuing BTech in Software Engineering from Delhi Technological University. I develop apps, create websites and blog about my app experiences.

Read more:
How to create your first Windows Phone app
How to change the App name and Tile name of your Windows phone app
Data binding in Windows Phone app – One way binding
Close