Implementing advert in Windows Phone app using Inneractive with CSharp
This article explains how to implement location based NAX ad (Banner) in your Windows Phone 8 application.
One of the new ways of advertising in Windows Phone application is to use Nokia Ad Exchange (NAX), powered by Inneractive. If you live in country where you can’t use Microsoft Ad Exchange, you can easily use NAX to earn some money from your Windows Phone app.
NAX is a mobile in-app advertising exchange offering access to the top ad networks in the world. With one API and one partner, you'll get access to over 120 ad agencies and networks, and you only need PayPal account to get your money.
The key NAX features are:
- Optimization across 120+ ad networks
- Payment enabled in over 200 countries
- Manage your own ad campaigns to promote your app
- Powerful ad performance dashboard
- NAX is free for developers
This article shows how to implement location based NAX ad (Banner) in your Windows Phone 8 application. The instructions complement the Windows Phone SDK guidelines on Inneractive wiki.
Step 1 – Register and download SDK
First what you need to do is to register on https://nax.nokia.com. After that you need to download SDK from SDKs page for Windows Phone 8. Current version is 1.1.3 (14 February 2013).
I propose you to look at Ad Placement Strategy.html document in folder Documentation with suggestions where to put your advert. The selected location influences how much will you earn from each ad.
Step 2 – Put ad files into Windows Phone project
From the InneractiveAdSDK folder of the extracted SDK, copy files to the root of your Visual Studio project (root for simplicity only, you can put these files in a separate folder):
- InneractiveAdLocation.cs (use this file only if you want to use location based ad in your WP app)
and then in Visual Studio for your Project do Add/Existing Item and choose both of the files.
Step 3 – Register NAX add dll file
You need to register Inneractive.Ad.dll file. Use References/Add Reference, click Browse button and find dll file from your Windows Phone solution.
After successful adding of dll file you need to get this reference:
Step 4 – Include capabilities
In order to NAX work in your app you need to activate some of the capabilities. From Properties/WMAppManifest.xaml file activate next check boxes in Capabilities section:
Step 5 – Display NAX ad in XAML
First, you need to add control in XAML where your ad will be positioned. We will use NAX control StackPanel using Grid:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel Height="53" Name="nax_control" Grid.Row="1">
List of supported ad sizes:
- 300 x 50
- 320 x 53
- 300 x 250 (Rectangle)
- 320 x 480 (Full Screen)
In this example we will use 320x53 pixel size on the bottom of the page using Grid.
The final result is:
Step 6 – C# code for NAX
After adding control in XAML code we need to write some code using C#. First we need to add two namespace in page where we want to put our ad control, in this case MainPage.xaml.cs with:
I recommend you include namespace:
NetworkInformation is to check if Internet connection is available with method: DeviceNetworkInformation.IsNetworkAvailable.
Then define optionalParams before main constructor in the class. All logic are in two methods MainPage_Loaded(): and iaLocation_Done()
public partial class MainPage : PhoneApplicationPage
Dictionary<InneractiveAd.IaOptionalParams, string> optionalParams;
// Sample code to localize the ApplicationBar
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
private void MainPage_Loaded(object sender, RoutedEventArgs e)
// Watch location
IaLocationClass iaLocation = new IaLocationClass();
iaLocation.Done += new System.EventHandler<IaLocationEventArgs>(iaLocation_Done);
optionalParams = new Dictionary<InneractiveAd.IaOptionalParams, string>();
optionalParams.Add(InneractiveAd.IaOptionalParams.Key_OptionalAdWidth, "320"); //ad width
optionalParams.Add(InneractiveAd.IaOptionalParams.Key_OptionalAdHeight, "53"); //add height
//Show Add Banner. Remarks: pay attention to use Application Id from NAX
//nax_control.Childred.Count()==0 => just to add one banner control on a page. Without this, code would add as many banners as you navigate to page where banner is placed
if (optionalParams != null && nax_control.Children.Count() == 0)
InneractiveAd iaBanner = new InneractiveAd("ApplicationId", InneractiveAd.IaAdType.IaAdType_Banner, 30, optionalParams);
void iaLocation_Done(object sender, IaLocationEventArgs e)
// Add location, if received
if (e != null && e.location != null)
catch (Exception ex)
System.Diagnostics.Debug.WriteLine("Error: " + ex.ToString());
Step 7 – AppId generation
You need to enter information including:
- Mobile platform
- Application name
- Does your app use location
After this you get generated Application Id for you application. This is crucial info to track your ad banner in your Windows Phone app in Nokia NAX dashboard.
Generated Application Id (AppID) that you need to use in your app (we call it ApplicationId_NAX in our app):
That is it!
I hope that you can earn some money using Nokia NAX ad.
- Implementing advert in Windows Phone app using Nokia NAX with C# (Spaso Lazarevic Blog - original source)
- Windows Phone SDK guidelines (Inneractive wiki)
- Nokia Ad Exchange