Using AdDuplex for Windows Phone 8 Silverlight app

AdDuplex is a cross-promotion network specifically targeted at Windows 8 and Windows Phone apps and games. You add our AdControl to your application and start serving ads for other apps. They serve ads for your app in return. The ratio is 8:10. This means for each 10 ads displayed in your app 8 of your ads will be displayed in other apps. The remaining 2 ads will be sold to support the service. The advantage of using adduplex is that it has a 100% fill rate. So it is often used as a secondary option to fill ad space if the primary ad network fails to deliver an ad.

You may consider using these as your primary ad networks

Here’s how you could use AdDuplex in your app.

Step 1. Register for a publisher account on AdDuplex

First thing first. If you don’t have an adduplex account, register on

http://www.adduplex.com


 

Step 2. Register a new app from your dashboard

Click on New App button in the dashboard to register a new app. We are building a Windows Phone 8 Silverlight application.


 

Enter the details for the app and choose an appropriate platform.

 

Once you create the app, note down the App ID which we will need while developing the application.

 

Step 3. Create a new Windows Phone 8 Silverlight app

Choose a Blank Windows Phone Silverlight template from installed templates and create a project.

 


 

Step 4. Add AdDuplex SDK to your project using Nuget

Next, add AdDuplex SDK to your project using Nuget package installer. You might want to see

How to integrate a Toolkit or Third party SDK with windows phone app using NuGet Package Manager

 


 

Step 5. Add the namespace for using AdDuplex in MainPage.xaml

Add the namespace for AdDuplex on pages where you wish to display ads

xmlns:adduplex=”clr-namespace:AdDuplex;assembly=AdDuplex.WindowsPhone”

Step 6. Add the adcontrol in your page

Now add the adcontrol in your page. Use the App id which you generated earlier.


 

Note:

  • You can preview your own exchange ad by setting IsTest property to true.
  • Make sure the whole AdControl is visible by verifying that it’s not obstructed by any other objects on your page.

Download full project AdDuplex-Example.zip

Adding Microsoft pubcenter ads in Windows Phone 8 apps

Recently lots of developers are seen facing problems with pubcenter ads. The impressions are at an all-time low still for some developers ads never show up (not even the test ads). There’s a little thing that developers should be mindful of and pubcenter will again start working for them. Heres a tutorial explaining how you could integrate pubcenter advertisements in your Windows Phone 8 apps.

Step 1. Visit pubcenter website and add a new application in it

Visit pubcenter website to create a new application and its ad unit

https://pubcenter.microsoft.com/

 

 

Note down the application ID and the ad unit ID which you just created.

Step 2. Add a reference to Microsoft.Advertising.Mobile.UI

Right click on the name of the project in solution explorer and choose Add>Reference. From the dialog box that appears choose Microsoft.Advertising.Mobile.UI and Microsoft.Advertising.Mobile and add it to your project. These references will enable you to use Microsoft’s pubcenter ads in your app. Instead of adding the reference you could have dragged and dropped the AdControl from Toolbox.

 


 

Step 3. Crucial step- Add the following capabilities carefully

Not adding all the required capabilities is main reason behind ads not showing up from pubcenter. Not choosing the right capabilities doesn’t lead to a syntax error and no error is reported while deploying the app. The following ID_CAP capabilities must be included in the manifest of the advertising-enabled app.

  • ID_CAP_IDENTITY_USER
  • ID_CAP_MEDIALIB_PHOTO
  • ID_CAP_NETWORKING
  • ID_CAP_PHONEDIALER
  • ID_CAP_WEBBROWSERCOMPONENT

Go to Solution Explorer> Properties> WMAPPManifest.xml and move over to capabilities tab. From there choose the following capabilities. You may require other capabilities based on the type of application you are building but these will be required for pubcenter.

 

Step 4. Add a reference to the page where you want to display ads

Add the following reference to the page where you wish to display ads from pubcenter.

xmlns:UI=”clr-namespace:Microsoft.Advertising.Mobile.UI;assembly=Microsoft.Advertising.Mobile.UI”

 

Step 5. Add the AdControl to your page

Add the AdControl to your page and insert the app id and ad unit id in it. If you are unsure where to put the code then have a look at the screen shot below. Also notice that the app id and ad unit id are set to test_client and Image480_80 respectively which is the default value. Also we have added an error occurred event handler.

Note: While debugging the app on emulator ads won’t show up if you are using a real app id and ad unit id. Instead if you use test values then a default ad will be visible    

Step 6. Add the error occurred event handler in code behind

You could use this event handler while debugging to know the reason for ads not appearing in the app. Most of the times if the ad control is correctly configured the reason for ads not appearing is low fill rates. Also you could use this event handler to load ads from another provider if ads from pubcenter fails. The code snippet show how you could add Google Admob’s ads when pubcenter fails to get an ad.

Here’s an article explaining how you could add Google AdMob in your Windows Phone 8 app.

 

Note

A few users have claimed that they can’t find this event trigger in their ad control. They might not be using the latest Ad SDK.

When you run the app in the emulator ads should now appear. Here’s a screenshot of the sample app i built.

Capture

 

Get the full source code of the app here,

Download full project source code pubcenter.zip

Using in App purchase to implement `Block Ads’ Feature in Windows Phone app

In my last blog post I explained how to add in app purchase in Windows Phone app. In this post I will show how IAP can be used to implement `Block Ads’ feature. Suppose you have a free app in the marketplace with in app advertisements. Most likely you wish to keep the app free so that it gets the most number of downloads. Still the advertisements may be annoying to some users and it would be great if you let your users remove those ads by making an in app purchase. Similar feature can also be achieved by implementing trial functionality in your app. I believe IAP is easier to implement and provides much more flexibility than trial apps. You have already seen how to set up IAP in your app so I will don’t discuss it again. Here is how you can implement the `Block Ads’ functionality

Step 1. Follow the following tutorial to set up in app purchase in your app

http://www.windowsapptutorials.com/windows-phone/add-in-app-purchases-in-your-windows-phone-app/

Step 2. Set up in app advertising in your app

If you haven’t added in app ads in your app then you could follow this tutorial to add Google Admob in your app.

http://www.windowsapptutorials.com/windows-phone/how-to-use-google-admob-in-windows-phone-app/

Step 3. Create a public Class AppSettings global to the project

Define a public class AppSettings which is global to the whole project with two public data variables DISPLAYADS and ISADBLOCKERACTIVE. You can define a public class by placing it just below the namespace of the project. In the sample provided I have defined it in App.xaml.cs just below the namespace of my project WAT_Test.

Step 4. Code to assign values to DISPLAYADS and ISADBLOCKERACTIVE

We will update the values of these variables when the app is launched and check whether the user has purchased the IAP to remove ads. If he has purchased it then ISADBLOCKERACTIVE will be set to true and DISPLAYADS will be set to false.

in_app

When I discussed how to use google admob in an app, I showed that it can be done through XAML or using C# code. So here too I will discuss how to block ads when it has been placed using XAML or via C#.

Blocking ads that were placed using XAML

  • Add a reference to your project in App.xaml as shown below in file reference.xaml
  • Add a new application resource ApplicationSettings which will use the AppSettings class in the section of Application.Resources as shown below in file local.xaml

in_app

  • Add a value converter class in App.xaml.cs named BooleanToVisibilityConvertor. This class implements IValueConverter converts a boolean value to an equivalent visibility and vice-versa.
  • Add a new application resource BooleanToVisibilityConverter in Application.Resources as shown in local.xaml file below
  • Now you can modify your AdView code for Admob to place a visibility condition as shown in the code adview.xaml

 


Blocking ads that were placed using C#

This is much simpler and you just need to check whether DISPLAYADS is true or false before calling admob() function.

These screen shots show that earlier ads were being displayed in the app but after IAP they didn’t appear. Be assured it wasn’t coincidence as I have getting 100% fill rate for Google Admob for the past few days.

Download full project WAT_Test.zip